Reported April 2026
Verkadastring

Find Valid IP Addresses

Reported by candidates from Verkada's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Verkada OA. Under 2s to a working solution.
Founder's read

Verkada sent you a file system scanner in April 2026, and it's asking you to extract and validate IPv4 addresses from text files. You're given a root directory, a list of file paths and contents, and you need to pull out every whitespace-separated token that looks like an IP address, validate it against strict rules (four octets, 0-255 each, no leading zeros except for 0 itself), and return them sorted. This is a string parsing problem wrapped in a file traversal task. StealthCoder will have your back if you freeze on the validation logic.

The problem

You are given a root directory path and a representation of files in a file system. Each file is represented as [path, content], where path is the full path to the file and content is the file's text. Consider only files whose path lies under the given root directory. Scan those files recursively and collect every whitespace-separated token that is a valid IPv4 address. A token is a valid IPv4 address if it has exactly four decimal octets separated by dots, each octet is in the range 0 to 255, and no octet has a leading zero unless the octet is exactly 0. Return all valid IPv4 addresses found in the scanned files, sorted in lexicographic order. If the same valid address appears multiple times, keep each occurrence. Function Description Complete the function findValidIpAddresses in the editor below. findValidIpAddresses has the following parameters: Returns The source thread did not provide explicit numeric bounds.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick here is separating the file system traversal from the IP validation. Filter files by root path first, then tokenize by whitespace across all matching files. The real work is the validator: split each token on dots, check length equals 4, verify each octet is 0-255, and reject any with leading zeros (except the token '0' itself). Common pitfall is forgetting that '01' is invalid but '0' is valid, or not handling the case where an octet is greater than 255. Build a helper function for validation and reuse it. The lexicographic sort is straightforward once you have the list. StealthCoder handles the edge cases around leading zeros and boundary checks if you blank on the validation rules during the live OA.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Find Valid IP Addresses cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder
⏵ The honest play

You've seen the question. Make sure you actually pass Verkada's OA.

Verkada reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Valid IP Addresses FAQ

Do I need to handle directory traversal, or is the file list already flattened?+

The file list is given as [path, content] pairs. Filter those pairs by checking if the path starts with (or is under) the root directory. You don't need recursive OS-level traversal; just filter the input array and process matching files.

What makes an octet invalid besides being out of range 0-255?+

Leading zeros. '192.168.001.1' is invalid because '001' has a leading zero. The only exception is the single digit '0', which is always valid. So '0.0.0.0' is valid, but '00' or '01' is not.

If the same IP appears three times across files, do I return it three times?+

Yes. The problem says 'if the same valid address appears multiple times, keep each occurrence.' You're collecting all instances, not deduplicating. Sort the full list, including duplicates.

How do I split by whitespace without getting tripped up by mixed delimiters?+

Most languages have a built-in split() or split() regex that handles spaces, tabs, newlines as one. Iterate through all files, concatenate their contents or process line by line, and split each piece by whitespace. Each token is a candidate IP.

Is this problem as hard as it sounds, or is it mostly pattern matching?+

Mostly pattern matching and validation. The file filtering is trivial. The IP validation is the only complex part, but it's just string manipulation and range checks. Once you nail the validator function, the rest is glue code.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Verkada.

OA at Verkada?
Invisible during screen share
Get it