Showing 7 questions
Simulate a robot's movement on an infinite grid based on a sequence of commands and obstacles. Determine the square of the robot's final Euclidean distance from the origin.
#1. Walking Robot Simulation
Design a data structure that acts as a Least Recently Used (LRU) cache. Implement methods to get and put key-value pairs, evicting the least recently used entry when the cache is full.
#2. LRU Cache
Design a system to shorten long URLs into tiny URLs and then retrieve the original URL from the shortened version. You need to implement both encoding and decoding functionalities.
#3. Encode and Decode TinyURL
Implement an in-memory file system with basic operations like creating directories, adding files, and listing contents. The file system should support path-based navigation.
#4. Design In-Memory File System
Imagine a grid representing rooms, some empty, some with walls, and some with gates. Fill each empty room with the distance to its nearest gate.
#5. Walls and Gates
Simulate the basic operations of a text editor. Implement functions to add text, delete characters, and move the cursor.
#6. Design a Text Editor
Implement a Tic-Tac-Toe game where players take turns placing their marks. Design the game logic to efficiently determine the winner after each move.
#7. Design Tic-Tac-Toe