Implement Employee Validation and Snake
Company: Amplitude
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
This interview covered two coding tasks:
1. **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.
2. **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.
Quick Answer: 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.