Showing 1115 questions
You're given a directed graph. Determine the minimum number of edges you need to reverse so that every node becomes reachable from node 0.
#1. Minimum Edge Reversals So Every Node Is Reachable
Find two numbers in a given array that add up to a specific target value, and return their indices. Essentially, you need to efficiently locate the pair that satisfies the sum requirement.
#2. Two Sum
Determine if a given word is considered valid based on a specific set of rules or constraints. The goal is to check if the input string adheres to the specified validation criteria.
#3. Valid Word
Determine if a string containing parentheses is valid. A valid string has matching and properly nested opening and closing parentheses.
#4. Valid Parentheses
Given a sorted array, remove the duplicate elements in-place such that each unique element appears only once. Return the new length of the array.
#5. Remove Duplicates from Sorted Array
Traverse a given matrix in a spiral pattern, returning all elements in the order you visit them. Essentially, walk around the matrix layer by layer, adding elements to a list.
#6. Spiral Matrix
The problem asks you to find the total number of distinct palindromic subsequences within a given string. Remember that subsequences don't have to be contiguous.
#7. Count Palindromic Subsequences
Given a number 'n', generate all possible well-formed (balanced) parentheses strings of length 2*n. For instance, if n=3, you need to create all valid combinations like '((()))', '(()())', etc.
#8. Generate Parentheses
Determine whether an integer is a palindrome. That is, it reads the same forwards and backward.
#9. Palindrome Number
You are given two sorted integer arrays. Merge the second array into the first one, maintaining the sorted order.
#10. Merge Sorted Array
You are given a collection of intervals. Merge all overlapping intervals into a single interval and return the result.
#11. Merge Intervals
You're given resources and machine blueprints. Determine the maximum number of identical alloys you can create by optimally distributing your resources across the machines.
#12. Maximum Number of Alloys
Find the median of two sorted arrays. The arrays can be of different sizes, and you should aim for an efficient solution.
#13. Median of Two Sorted Arrays
Given a list of words, group together all the anagrams. Anagrams are words that contain the same letters rearranged.
#14. Group Anagrams
You're given a list of job difficulties and a number of days. Find the minimum total difficulty to schedule all jobs, ensuring at least one job is done each day.
#15. Minimum Difficulty of a Job Schedule
Determine the total number of continuous subarrays within a given array that sum up to a specific target value, k.
#16. Subarray Sum Equals K
Convert a Roman numeral string into its corresponding integer value. The input string will represent a valid Roman numeral.
#17. Roman to Integer
Find the longest palindromic substring within a given string. A palindromic substring reads the same forwards and backward.
#18. Longest Palindromic Substring
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.
#19. Trapping Rain Water
Determine if any value appears at least twice in an array of numbers. Return true if duplicates exist; otherwise, return false.
#20. Contains Duplicate