714215. Wifi Range

Easy

Wifi Range

Summary

The problem Wifi Range is an easy-level algorithmic challenge that involves calculating the range of a wifi signal. The given input is a string representing a wifi signal strength, and the task is to determine whether the signal can be received at a certain distance from the source.

Detailed Explanation

To solve this problem, we can use a simple string manipulation approach. The idea is to iterate through the characters in the string and count the number of characters that are greater than or equal to a given threshold (representing the minimum signal strength required for reception).

Here's a step-by-step breakdown of the solution:

  1. Initialize a variable range to 0, which will store the maximum distance at which the wifi signal can be received.
  2. Iterate through each character in the string from left to right.
  3. For each character, check if its value is greater than or equal to the minimum signal strength required for reception (let's call this value threshold).
  4. If a character meets the threshold condition, increment the range variable by 1.
  5. After processing all characters in the string, return the maximum range value.

Here's an ASCII art diagram illustrating the problem:

+---------------+
| Signal Strength |
|  XXXXXXXXXXXX  |
|  XXXXXXXXXX   |
|  XXXXXXX     |
|  X          |
+---------------+

Time complexity analysis: O(n), where n is the length of the input string.

Space complexity analysis: O(1), as we only need a single variable to store the maximum range.

Optimized Solutions

Java

View on GeeksforGeeks
public class WifiRange {
    public static int wifiRange(String signalStrength) {
        int range = 0;
        for (char c : signalStrength.toCharArray()) {
            if (c >= 'X') { // assume 'X' represents minimum signal strength
                range++;
            }
        }
        return range;
    }
}

DevExCode

Master coding interviews with Leetcode, system design, TechBit, QuickLearn, DevTips, Tech Battles, and career services.

© 2026 DevExCode. All rights reserved.