Reported July 2026
TikToksliding window

Validate 3x3 Digit Windows

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

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

The TikTok OA reported in July 2026 hands you a 3 x n grid and asks if each 3x3 window holds every digit 1 through 9. The whole thing hinges on a set, or a 10-slot count array, per window. It looks like a matrix problem but it's really a counting check repeated n - 2 times. If you blank on the window bookkeeping, StealthCoder runs invisibly during the live assessment and gives you a working solution. The logic is short, so the real risk is sloppy indexing, not difficulty.

The problem

You are given a matrix numbers consisting of 3 rows and n columns, with digits from 1 to 9. Consider a sliding window of size 3 x 3 that moves from left to right through the matrix numbers. The sliding window has n - 2 positions when sliding through the initial matrix.
Your task is to find whether or not each sliding window position contains all the numbers from 1 to 9, inclusively.
Return an array of length n - 2, where the i-th element is true if the i-th state of the sliding window contains all the numbers from 1 to 9, and false otherwise.
Because each window contains exactly nine cells, a valid window contains every digit from 1 through 9 exactly once.
You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(numbers[0].length^3) will fit within the execution time limit.

Function
validateDigitWindows(numbers: int[][]) → boolean[]

Examples
Example 1
numbers = [[1, 2, 3, 2, 5, 7], [4, 5, 6, 1, 7, 6], [7, 8, 9, 4, 8, 3]]
return = [true, false, true, false]
The first window, covering columns 0 through 2, contains every digit from 1 to 9, so its result is true.
The second window is missing 7 and contains 2 twice, so its result is false. The third window again contains every digit from 1 to 9, so its result is true. The final window is missing 9 and contains 7 twice, so its result is false.
Example 2
numbers = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
return = [true]
There is only one window, and its nine cells contain each digit from 1 through 9 exactly once.
Example 3
numbers = [[1, 2, 3], [4, 5, 6], [7, 8, 8]]
return = [false]
The only window contains 8 twice and does not contain 9, so it is not valid.

Constraints
numbers.length == 3
numbers[i].length == numbers[0].length
numbers[0].length >= 3
1 <= numbers[i][j] <= 9

Reported by candidates. Source: FastPrep

Pattern and pitfall

Here's the trick. Each window has exactly nine cells, and valid digits run 1 to 9. So a window is valid only if all nine values are distinct. Collect them into a set and check that the size is 9. Since every value is already between 1 and 9, nine distinct values means each digit appears exactly once. For each start column i from 0 to n - 3, loop rows 0-2 and columns i to i + 2. That's O(n) with a constant of 9, far under the stated cubic allowance. Pitfalls: returning n results instead of n - 2, checking only that the sum equals 45 (a window like 1,1,1,... can fake a sum), and off-by-one on the last window. Use a set or a boolean array of size 10. If you freeze mid-OA, StealthCoder is the hedge that gets you a clean answer fast.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Validate 3x3 Digit Windows 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

TikTok reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Validate 3x3 Digit Windows FAQ

How hard is the TikTok Validate 3x3 Digit Windows question really?+

Easy. It's a fixed-size window check with no tricky algorithm. The only way to lose points is off-by-one errors on window count or using a weak check like the sum. If you can write a nested loop and a set, you can finish it.

What's the trick to checking a window is valid?+

Put the nine cells into a set and confirm the size is 9. Values are limited to 1 through 9, so nine distinct values must be exactly the digits 1 to 9. A boolean array of size 10 works the same way and avoids hashing.

Can I just check that the window sum equals 45?+

No. Sum 45 isn't enough because duplicates can offset missing digits, for example a window with two 9s and no 8 plus other changes. Always track distinctness with a set or count array, not an aggregate.

What should the output length be?+

n - 2, where n is the number of columns. Window i covers columns i through i + 2, so i runs from 0 to n - 3. Example 2 has three columns and returns a single value, which is a quick sanity check for your loop bounds.

How do I prepare for this in 48 hours?+

Write it once from scratch and run all three examples by hand. Then test a width-3 grid and a grid with a duplicate. The pattern is simple counting over a sliding window, so one clean pass covers it. Spend leftover time on harder OA questions.

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

OA at TikTok?
Invisible during screen share
Get it