Showing 33 questions
Imagine a grid with horizontal and vertical bars that can be removed. Find the largest possible square you can cut out by strategically removing some of these bars to create a square-shaped hole.
#1. Maximize Area of Square Hole in Grid
You are given an array of integers. Find the minimum positive starting value so that the step-by-step sum is never less than 1.
#2. Minimum Value to Get Positive Step by Step Sum
You're given two arrays. For each number in the first array, find the next larger number in the second array.
#3. Next Greater Element I
You're given an array containing only 0s, 1s, and 2s. Sort the array in place so that elements of the same value are grouped together.
#4. Sort Colors
You're given a list of meals, each with a certain deliciousness value. Determine how many pairs of meals have a combined deliciousness that is a power of two.
#5. Count Good Meals
You are given two sorted integer arrays. Merge the second array into the first one, maintaining the sorted order.
#6. Merge Sorted Array
Determine if a string containing parentheses is valid. A valid string has matching and properly nested opening and closing parentheses.
#7. Valid Parentheses
Determine if a number is a 'happy number'. A happy number eventually reaches 1 when replaced by the sum of the squares of its digits, repeating the process until it does.
#8. Happy Number
Given a list of daily temperatures, find how many days you have to wait until a warmer temperature. Return a list where each element represents the waiting days for each day's temperature.
#9. Daily Temperatures
Convert a given integer into its Roman numeral representation. You need to understand the mapping between integer values and Roman symbols to perform the conversion accurately.
#10. Integer to Roman
Two people, Alice and Bob, have candy bars of different sizes. Determine how to swap one candy bar from each person so that they both have the same total amount of candy.
#11. Fair Candy Swap
Determine if it is possible to finish all courses given prerequisite relationships between them. Essentially, detect if a cycle exists in the course dependencies.
#12. Course Schedule
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.
#13. Maximum Profit in Job Scheduling
Find the median of two sorted arrays. The arrays can be of different sizes, and you should aim for an efficient solution.
#14. Median of Two Sorted Arrays
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. These consecutive numbers do not need to be adjacent in the original array.
#15. Longest Consecutive Sequence
Given an integer n, determine how many structurally unique binary search trees can store values from 1 to n. Calculate the number of possible BST shapes for a given number of nodes.
#16. Unique Binary Search Trees
You're given a list of tasks with varying durations and a maximum session time. Determine the fewest work sessions needed to complete all tasks, given each task must be finished within a single session.
#17. Minimum Number of Work Sessions to Finish the Tasks
Determine the total number of continuous subarrays within a given array that sum up to a specific target value, k.
#18. Subarray Sum Equals K
Find the element that appears more than n/2 times in a given array of size n. Essentially, you need to identify the majority element.
#19. Majority Element
You are given a string and two smaller strings with associated scores. Find the maximum possible score by repeatedly removing either of the smaller strings as substrings from the original string and summing their scores.
#20. Maximum Score From Removing Substrings