Showing 134 questions
You are given a collection of rectangles. Calculate the total area covered by all the rectangles, considering overlaps.
#1. Rectangle Area II
Find the largest rectangular area that can fit within a histogram defined by an array of bar heights. You are given an array representing the height of bars, where each bar has a width of 1.
#2. Largest Rectangle in Histogram
Imagine a landscape of varying heights. Calculate how much water can be trapped after it rains, considering the water level can rise from all sides, not just left and right like in the simpler version.
#3. Trapping Rain Water II
You are given a row of cards with associated points. Select k cards from either the beginning or end of the row to maximize your total score.
#4. Maximum Points You Can Obtain from Cards
Given an array representing the height of bars, calculate how much water can be trapped between them after rain. Think about finding the maximum height to the left and right of each bar.
#5. Trapping Rain Water
Simulate a movie rental system. Implement functionality to search, rent, return, and report movies based on price and customer demand.
#6. Design Movie Rental System
You are given a target amount and a sorted list of available coin values. Determine the fewest additional coin values you must add to the list so that you can form every integer value from 1 to the target amount using the available coins.
#7. Minimum Number of Coins to be Added
Calculate the score of students who tried to evaluate a given mathematical expression. Students may have made mistakes, so you need to consider all possible evaluation orders and compare them to the correct answer.
#8. The Score of Students Solving Math Expression
Find all numbers of a given length where the absolute difference between every two consecutive digits is equal to a specified value. Return these numbers as an array.
#9. Numbers With Same Consecutive Differences
Imagine two islands represented by ones in a grid of zeros and ones. Find the shortest path to connect the two islands by changing zeros to ones.
#10. Shortest Bridge
You're given an array and can perform operations to make all elements equal. Determine the minimum number of operations needed to achieve this by changing other elements to a single chosen value.
#11. Transform Array to All Equal Elements
You're given bags containing a number of balls. Determine the minimum largest number of balls a bag can have after a limited number of operations, where each operation involves splitting a bag into smaller bags.
#12. Minimum Limit of Balls in a Bag
Find the minimum cost to travel between cities, where you can use a limited number of discounts to reduce the cost of certain roads. You need to determine the optimal path considering both road costs and discount usage.
#13. Minimum Cost to Reach City With Discounts
Given an array of integers, find the number of unique triplets where the bitwise AND of the three integers is equal to zero.
#14. Triples with Bitwise AND Equal To Zero
Koko wants to eat all the bananas in some piles within a certain time. Find the minimum eating speed that allows her to finish on time.
#15. Koko Eating Bananas
You're given two integer arrays. Modify the arrays with a series of swaps to make them unequal at every index, minimizing the total cost of those swaps. Find that minimum cost.
#16. Minimum Total Cost to Make Arrays Unequal
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.
#17. Container With Most Water
Determine the minimum capacity needed for a ship to transport packages within a given number of days. You're given the weights of the packages and must find the smallest capacity that allows shipping all packages within the day limit.
#18. Capacity To Ship Packages Within D Days
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.
#19. Asteroid Collision
Find the length of the longest substring within a given string that contains no repeating characters. The substring must be contiguous.
#20. Longest Substring Without Repeating Characters