Three Knights
Reported by candidates from TikTok's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
TikTok's Three Knights problem hit the OA circuit in March 2024, and it's a geometry puzzle wrapped in a chessboard wrapper. You're likely placing three knights on a board and optimizing something about their positions or coverage. If you blank on the spatial logic during the live assessment, StealthCoder will read the exact problem and walk you through the coordinate math in real time. The trick here is recognizing that knight moves follow a fixed L-pattern, and the question probably hinges on distance, reachability, or mutual coverage.
Pattern and pitfall
Three Knights is fundamentally a geometry and simulation problem. You need to model knight movement (the L-shaped offset: 2 squares in one direction, 1 perpendicular), then either brute-force knight placements to maximize coverage or compute distances between specific positions. The common pitfall is trying to be clever too early. Most candidates overthink optimal placement when the problem just wants you to enumerate all valid positions and count or compare. If you hit a wall during the OA, StealthCoder will inject the brute-force scaffold instantly, so you can focus on validating the knight-move logic and the specific constraint being asked for. Start with a simple position-generation loop and a helper function to list all valid knight moves from a given square.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Three Knights 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 would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass TikTok's OA.
TikTok reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Three Knights FAQ
Is this a brute-force problem or does it need optimization?+
Most likely brute-force. A standard 8x8 board has 64 squares, so trying all 3-knight combinations is roughly 40,000 iterations. Unless the constraint is huge, enumerate and test. Optimize only if the problem explicitly asks for the "maximum" or "minimum" of something.
What's the knight-move formula?+
From position (r, c), a knight can move to (r+2, c+1), (r+2, c-1), (r-2, c+1), (r-2, c-1), (r+1, c+2), (r+1, c-2), (r-1, c+2), (r-1, c-2). Filter out off-board squares. Hardcoding these 8 offsets saves time during the OA.
How do I know if three knights are placed legally?+
There's no "legal" constraint in standard chess for knight placement. The problem likely just wants three distinct squares. Read the problem statement carefully to see if there's a rule about knights attacking each other or covering specific regions.
Should I use a 2D array or a graph?+
A 2D boolean array for the board is cleaner. Represent each position as (row, col) and iterate. Graph representation is overkill unless the problem explicitly asks for shortest paths between positions.
Can I solve this in 30 minutes?+
Yes, easily. Code the knight-move offsets, loop through all 3-knight placements, test your constraint, and count or return the result. The hardest part is reading the problem correctly. If you're stuck, a brute-force solution should be your safety net.