Lowest Number in an Open Range
Reported by candidates from TikTok's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The TikTok OA reported in September 2026 looks like a puzzle, but it's a single filtered scan. Given an array and a range, you return the smallest value strictly between the endpoints, or 0 if nothing fits. It's an easy array problem dressed up with a function name. The risk isn't difficulty, it's carelessness with the strict inequalities and the empty case. If your nerves spike and you blank on something this simple, StealthCoder runs invisibly during the live assessment as a safety net. Still, you should be able to write this from memory in two minutes. Here's what to watch for.
The problem
You are given an array of positive integers numbers and a two-element array nRange describing a number range whose endpoints satisfy nRange[0] ≤ nRange[1]. Return the smallest value in numbers that lies strictly between the two endpoints. In other words, find the smallest numbers[i] such that nRange[0] < numbers[i] < nRange[1]. If no value satisfies both strict inequalities, return 0. Function findLowestInRange(numbers: int[], nRange: int[]) → int Examples Example 1 numbers = [11,4,23,9,10] nRange = [5,12] return = 9 The values strictly between 5 and 12 are 11, 9, and 10. Their minimum is 9. Example 2 numbers = [1,3,2] nRange = [1,1] return = 0 No integer can be strictly greater than 1 and strictly less than 1 at the same time, so the result is 0. Example 3 numbers = [7,23,3,1,3,5,2] nRange = [2,7] return = 3 The qualifying values are 3, 3, and 5. The smallest is 3. Constraints 1 ≤ numbers.length ≤ 100 1 ≤ numbers[i] ≤ 100 nRange.length = 2 Both values in nRange are positive integers that fit in a signed 32-bit integer. nRange[0] ≤ nRange[1]
Reported by candidates. Source: FastPrep
Pattern and pitfall
Walk the array once and keep a running minimum of values where low < x < high. Start the minimum as a sentinel, like infinity or a null flag, and return 0 if it never changed. That's O(n) time and O(1) space. The pitfalls are small but real. Using <= instead of < breaks Example 1 style cases where an endpoint appears in the array. Initializing the answer to 0 is wrong, because 0 is also your not-found value, so a min comparison never updates. Example 2 with [1,1] needs no special branch, since the strict check rejects everything naturally. Don't sort, it's unnecessary work. Duplicates don't matter either. If you freeze on the live OA, StealthCoder can hand you the loop, but the logic is just filter then min, and you can type it yourself.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Lowest Number in an Open Range 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass TikTok's OA.
TikTok reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Lowest Number in an Open Range FAQ
How hard is the TikTok lowest-in-range question really?+
Very easy. It's a single pass with a filter and a minimum. The constraints are tiny, with at most 100 elements. Most failures come from sloppy edge handling, not algorithm choice. Expect to finish quickly and spend leftover time testing the empty and equal-endpoint cases.
What's the trick to this problem?+
There isn't a clever one. Check low < x < high strictly, track the smallest match, and return 0 if none matched. Initialize with a sentinel that isn't a valid answer, like a very large number, so the not-found case is detectable.
Do I need to sort the array?+
No. Sorting costs O(n log n) and adds nothing. A linear scan is simpler and faster. You'd only need to look at each element once, compare it to both endpoints, and update the running minimum when it qualifies.
What edge cases should I test before submitting?+
Test equal endpoints like [1,1], where the answer must be 0. Test values that equal an endpoint, which must be excluded. Test duplicates inside the range, and an array where nothing falls inside. Also confirm your sentinel doesn't leak out as the result.
How do I prepare in 48 hours for an OA like this?+
Practice writing basic array scans cleanly: filter, min, max, counting. Get fast at reading the strict versus inclusive wording. Then rehearse a couple of medium problems with hash maps and two pointers, since TikTok OAs usually mix easy and harder questions.