Showing 14 questions
You're given a rectangle represented by a matrix. Implement functions to update values within specified subrectangles and retrieve the value at a given coordinate.
#1. Subrectangle Queries
Imagine you're standing at a fixed location looking at points on a 2D plane. Determine the maximum number of points you can see within a given field of view by rotating your position.
#2. Maximum Number of Visible Points
You are given equations represented by pairs of variables and their corresponding values. Your task is to evaluate queries based on these equations, determining the value of expressions if possible, or returning -1.0 if not.
#3. Evaluate Division
You are given an array representing the heights of vertical lines. Find two lines that, together with the x-axis, form a container that holds the most water.
#4. Container With Most Water
Determine if a third string can be formed by interleaving the characters of two other given strings, maintaining their original order. In other words, check if the third string is an interleaving of the first two.
#5. Interleaving String
You are given a collection of intervals. Merge all overlapping intervals into a single interval and return the result.
#6. Merge Intervals
Implement a thread-safe blocking queue with a fixed capacity. Your solution should include methods for enqueueing and dequeueing elements, handling full and empty queue scenarios appropriately.
#7. Design Bounded Blocking Queue
Find the maximum value within each sliding window of a given size as it moves across an array.
#8. Sliding Window Maximum
Determine if a set of points in a 2D plane are symmetric about a vertical line. That is, check if there exists a vertical line such that for each point, there's a corresponding point reflected across it.
#9. Line Reflection
Find the shortest path from the top-left to the bottom-right corner of a grid. You can eliminate a limited number of obstacles along the way.
#10. Shortest Path in a Grid with Obstacles Elimination
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
Design a data structure to calculate the moving average of a stream of numbers. The moving average is calculated over a sliding window of a specified size.
#12. Moving Average from Data Stream
Multiply two sparse matrices represented as arrays of arrays. Optimize your solution to avoid unnecessary calculations on zero elements.
#13. Sparse Matrix Multiplication
Find the overlapping intervals between two lists of intervals. Return a new list containing only the intersecting intervals.
#14. Interval List Intersections