Zoho L3 Coding Round June 15 2024 || Design Snake Game
Summary
I recently had my third round coding interview with Zoho, where I was tasked with designing a Snake Game.
Full Experience
Hi everyone, I recently had my third round interview with Zoho, and I wanted to share my experience and the question I encountered. I believe this could be helpful for those preparing for similar interviews. It was a challenging but fun problem that tested my understanding of data structures and algorithms.
Interview Questions (1)
You are tasked with designing a Snake game for a device with a screen size specified by the user (height x width). Here are the specifics: The snake starts at the top left corner (0, 0) with a length of 1 unit. You are given an array called food where food[i] = (ri, ci) represents the row and column position of a piece of food. The snake eats the food to grow and increase the score by 1. Food pieces appear sequentially on the screen, meaning the next piece of food will only appear after the current piece has been eaten. It is guaranteed that food will not appear on a block currently occupied by the snake. The game ends if the snake goes out of bounds (hits a wall) or if the snake's head collides with any part of its body. You need to implement the Snake Game based on these rules. Additional Details: Time to complete: 3 hours.
Preparation Tips
For future candidates, I'd recommend practicing implementing various game simulations. Focus on edge cases like boundary conditions and self-collision detection. Optimizing for efficiency, especially in updating the snake’s position and checking collisions, is also key.