Showing 12 questions
Implement a SQL class that supports basic database operations: creating tables, inserting rows, deleting rows based on a condition, and selecting specific columns from rows that match a condition.
#1. Design SQL
You're given a list that can contain integers or other nested lists. Implement an iterator to flatten this structure and yield only the integers one by one.
#2. Flatten Nested List Iterator
Simulate a simplified Excel sheet and implement the SUM formula. You'll need to parse cell ranges and calculate their sum.
#3. Design Excel Sum Formula
Implement a multithreaded web crawler to efficiently explore and retrieve pages from a website, respecting the website's rules.
#4. Web Crawler Multithreaded
Design an algorithm to encode a list of strings into a single string and then decode the single string back to the original list of strings.
#5. Encode and Decode Strings
Design a key-value store that supports storing values associated with timestamps. You should be able to retrieve the value for a given key at the latest timestamp less than or equal to a given time.
#6. Time Based Key-Value Store
Given an absolute file path (Unix style), simplify it by resolving redundant separators, directory names, and navigating back up the directory structure. Return the simplified canonical path.
#7. Simplify Path
Simulate a basic memory allocator. You'll need to allocate blocks of memory, track their IDs, and free them based on their ID.
#8. Design Memory Allocator
Find the largest value within each sliding 3x3 submatrix of a given matrix. Return a matrix containing these largest local values.
#9. Largest Local Values in a Matrix
Imagine a paint bucket tool. Given a starting pixel and a color, change all connected pixels of the same original color to the new color.
#10. Flood Fill
You're given a list of asteroids, each with a size and direction (positive is right, negative is left). Figure out which asteroids will survive after all collisions happen.
#11. Asteroid Collision
Convert an IP address and a number of addresses to a CIDR block representation. Find the smallest list of CIDR blocks that covers the specified range of IP addresses.
#12. IP to CIDR