Showing 17 questions
Implement a snapshot array where you can update elements and take snapshots of the array at any time. Later, you should be able to retrieve the value of an element at a specific snapshot.
#1. Snapshot Array
You're given a list of jobs with start times, end times, and profits. Find the maximum profit you can obtain by scheduling a subset of jobs that don't overlap.
#2. Maximum Profit in Job Scheduling
Find the overlapping intervals between two lists of intervals. Return a new list containing only the intersecting intervals.
#3. Interval List Intersections
Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
#4. Non-overlapping Intervals
You're given a secret word and a list of possible guesses. Your goal is to guess the secret word by making a limited number of guesses and receiving feedback on how many letters match in the correct positions.
#5. Guess the Word
Implement a basic calculator to evaluate a simple expression string. The expression can contain non-negative integers, '+', '-', '*', '/' operators, and spaces; integer division should truncate toward zero.
#6. Basic Calculator II
You are given a matrix (a 2D array). Your task is to compute and return its transpose, effectively swapping rows and columns.
#7. Transpose Matrix
You're given a list of folder paths. Identify and remove all folders that are sub-folders of another folder in the list, returning only the root folders.
#8. Remove Sub-Folders from the Filesystem
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.
#9. LRU Cache
You are given k sorted lists. Combine all of their elements into a single sorted list and return it.
#10. Merge k Sorted Lists
You are given two sorted integer arrays. Merge the second array into the first one, maintaining the sorted order.
#11. Merge Sorted Array
Design a key-value store that supports storing values with timestamps. You should be able to retrieve the latest value for a key that's less than or equal to a given timestamp.
#12. Time Based Key-Value Store
You are given a grid of oranges, some fresh, some rotten. Rotten oranges contaminate adjacent fresh oranges; find the minimum time until all oranges are rotten.
#13. Rotting Oranges
You're given an image represented as a grid of numbers. Calculate the smoothed value for each cell by averaging the values of its surrounding neighbors, including itself.
#14. Image Smoother
Find the longest path between any two nodes in a binary tree. The path may or may not pass through the root.
#15. Diameter of Binary Tree
Determine the number of '1' bits present in the binary representation of a given integer. Essentially, count how many bits are set to one.
#16. Number of 1 Bits
Evaluate a string expression that includes basic arithmetic operations (+, -, *, /) and parentheses. Handle operator precedence and calculate the final result.
#17. Basic Calculator III