Count Right-or-Down Word Paths with One Turn
Updated
Problem statement
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[]) → intExamples
Example 1
board = ["abc","def","ghi"]words = ["abc","adg","aei"]return = 2Horizontal, vertical, and one-turn paths are all eligible.
Example 2
board = ["aa","ab"]words = ["a"]return = 3Each matching cell contributes once.
Constraints
1 <= board rows, columns <= 501 <= words.length <= 1001 <= words[i].length <= 100
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Repair One Movement InstructionOpenAI · OAOpenAI interview questions
- Count Straight-Line Word Occurrences in a GridOptiver · OAOptiver interview questions
- Count Straight-Line Word Occurrences in a GridVisa · OAVisa interview questions
- Count Grid Words with One TurnCapital One · OACapital One interview questions
- Find a Word in Eight Straight DirectionsIntuit · OAIntuit interview questions
- Flip Rows and Columns, Count ZerosNutanix · OANutanix interview questions
- Hidden ArtifactsIMC Trading · OAIMC Trading interview questions
- Lexicographically Smallest Grid Path with One Letter ChangeInfosys · OAInfosys interview questions
- Balance a Chemical EquationMicrosoft · OAMicrosoft interview questions
- Simulate a Deterministic Finite AutomatonPoint72 · OAPoint72 interview questions