Implement Employee Validation and Snake
AmplitudeSoftware Engineer · OnsiteLast updated
This question evaluates recursion, graph traversal and cycle-detection concepts for hierarchical employee validation alongside state management, event-driven input handling and collision detection for a grid-based Snake game.
This interview covered two coding tasks:
- Employee validation
- Implement a function that validates a collection of employees against a set of business rules.
- Each employee can have direct reports, so validation must recursively process all descendants.
- Follow-up: extend the validation so it detects cycles in the reporting structure, for example when employee A indirectly reports back to employee A.
- Snake game
- Implement a simplified Snake game on a 2D grid.
- The game should handle keyboard input for up, down, left, and right movement.
- It should detect wall collisions.
- When the snake eats an apple, its length should increase by 1.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.