Katkat

Solve snake game, peak search, and task scheduling

IXL LearningSoftware Engineer · Technical Screen

Last updated

Solve snake game, peak search, and task scheduling evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

  1. Design a grid-based snake simulation that supports move(direction) operations on a W×H board. The snake grows when it consumes food at predetermined coordinates; return the score after each move or -1 if the snake hits a wall or itself. Specify the data structures to achieve O(
  2. average time per move and explain how you detect collisions and advance the food pointer.
  3. Given an integer array, find any index i such that nums[i] is strictly greater than its immediate neighbors (a local peak) in O(log n) time and O(
  4. space. Describe the algorithm, prove correctness, and discuss adaptations when duplicates are allowed.
  5. You are given tasks identified by characters and a non-negative cooldown n. Compute the minimum number of time slots to finish all tasks if each slot can execute one task or be idle, and outline how to construct one valid schedule. Extend your approach to handle distinct cooldowns per task.