Solve snake game, peak search, and task scheduling
IXL Learning
Jul 17, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
0
0
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(
average time per move and explain how you detect collisions and advance the food pointer.
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(
space. Describe the algorithm, prove correctness, and discuss adaptations when duplicates are allowed.
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.