Simulate robot moves on a grid
Company: Shopify
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates competency in grid-based simulation, state updates, boundary condition handling, and sequential command parsing. Commonly asked in Coding & Algorithms interviews to gauge correct implementation and edge-case reasoning, it assesses practical application more than abstract theory and can be extended to path reconstruction or obstacle-aware movement as follow-ups.
Constraints
- 0-indexed coordinates
- blocked is optional
Examples
Input: (3, 3, (1, 1), 'UURDDL')
Expected Output: [2, 1]
Input: (1, 1, (0, 0), 'UDLR')
Expected Output: [0, 0]
Input: (3, 3, (0, 0), 'RRDDLL', [(0, 1)])
Expected Output: [2, 0]
Hints
- Check bounds before committing a move.