Reported December 2023
ZipRecruitersimulation

Count Right-or-Down Word Paths with One Turn

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

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

The ZipRecruiter OA reported in December 2023 looks like a word search, but the move set is the whole point. Right or down only, one turn max, and a 50x50 board against up to 100 words of length 100. If you try every path from every cell with plain backtracking, you'll blow up on long words. The real shape is simulation with a small state: position, index in the word, and whether you've turned yet. If you blank on the state design, StealthCoder is the safety net running invisibly during the live OA.

The problem

For each word, count distinct coordinate paths in board that spell it. A path starts anywhere, moves one cell right or down per character, and changes direction at most once. A path never leaves the board.
Sum occurrences over all words, counting duplicate words independently. A one-character occurrence is counted once per matching cell.

Function
countWordPaths(board: String[], words: String[]) → int

Examples
Example 1
board = ["abc","def","ghi"]
words = ["abc","adg","aei"]
return = 2
Horizontal, vertical, and one-turn paths are all eligible.
Example 2
board = ["aa","ab"]
words = ["a"]
return = 3
Each matching cell contributes once.

Constraints
1 <= board rows, columns <= 50
1 <= words.length <= 100
1 <= words[i].length <= 100

Reported by candidates. Source: FastPrep

Pattern and pitfall

Don't search blindly. With only right and down moves and at most one turn, a path is either a straight line, or a straight run in one direction followed by a straight run in the other. So for each start cell and word, you can enumerate the turn point instead of exploring branches. Or run a DP: dp[r][c][i][state], where state is 0 for no turn yet moving right, 1 for down with no turn, and so on. Count, don't enumerate. The pitfall is double counting. A straight path fits both 'right then none' and 'right then down with zero length', so define turns carefully. Single-character words count once per matching cell, and that's a special case. Duplicate words count independently, so just multiply by frequency or loop through them. Example 2 returns 3, which is a quick sanity test. StealthCoder is your hedge if the state machine gets tangled mid-assessment.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Count Right-or-Down Word Paths with One Turn 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 by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

ZipRecruiter reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Right-or-Down Word Paths with One Turn FAQ

What's the trick in the ZipRecruiter word paths problem?+

Treat each path as at most two straight segments. Either count with a DP over cell, word index, and direction state, or enumerate the turn cell. Both avoid exponential backtracking. The key is making sure straight paths aren't counted twice as turn variants.

How do I avoid double counting straight paths?+

Pick one canonical representation. For example, a path is 'right segment then down segment' or 'down segment then right segment', and require the second segment to have length at least 1. Straight paths are counted separately, once each. Test with Example 1, which expects 2.

How should I handle single-character words?+

Count every cell in the board that matches the character, once each. No direction exists for a length-1 word, so don't let your turn logic multiply it. Example 2 gives 3 because three cells hold 'a'.

Will brute force pass the constraints?+

Probably not. The board has up to 2500 cells, words reach length 100, and there are up to 100 words. Unpruned search from every cell is wasteful. Prune on character mismatch at minimum, and prefer DP or turn-point enumeration with a direction state.

How do I prepare for this in 48 hours?+

Write a grid DP with a small extra state, like a turn flag, from scratch. Then test on the two examples and a case with duplicate words. Practice reading the statement carefully for counting rules, since those details decide the answer.

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

OA at ZipRecruiter?
Invisible during screen share
Get it