Showing 256 questions
You are given a collection of intervals. Merge all overlapping intervals into a single interval and return the result.
#1. Merge Intervals
You are given k sorted lists. Combine all of their elements into a single sorted list and return it.
#2. Merge k Sorted Lists
Given a list of words, group together all the anagrams. Anagrams are words that contain the same letters rearranged.
#3. Group Anagrams
Given a set of distinct positive integers, find the largest subset where every pair of elements (i, j) in the subset satisfies either i % j == 0 or j % i == 0. Return this largest divisible subset.
#4. Largest Divisible Subset
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.
#5. LRU Cache
Given a grid representing land and water, count the number of distinct islands. An island is formed by connected land cells.
#6. Number of Islands
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.
#7. Two Sum
Find the length of the longest substring within a given string that contains no repeating characters. The substring must be contiguous.
#8. Longest Substring Without Repeating Characters
Find the length of the longest strictly increasing subsequence within a given array of numbers. A subsequence doesn't need to be contiguous, but the elements must maintain their original order.
#9. Longest Increasing Subsequence
Determine if a string containing parentheses is valid. A valid string has matching and properly nested opening and closing parentheses.
#10. Valid Parentheses
Find the longest palindromic substring within a given string. A palindromic substring reads the same forwards and backward.
#11. Longest Palindromic Substring
Find the k most frequent elements in a given array of numbers. Return the top k elements based on their frequency.
#12. Top K Frequent Elements
Find the maximum value within a sliding window of size k as it moves across an array. You'll need to efficiently update the maximum as the window slides.
#13. Sliding Window Maximum
You are given a list of meeting time intervals. Determine the minimum number of conference rooms required to accommodate all the meetings without any overlap.
#14. Meeting Rooms II
The goal is to transform a given integer to zero using a special set of bit manipulation operations. Find the minimum number of operations needed for this conversion.
#15. Minimum One Bit Operations to Make Integers Zero
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.
#16. Rotting Oranges
Given a binary tree, imagine you are standing on the right side of it. Return the values of the nodes you can see, ordered from top to bottom.
#17. Binary Tree Right Side View
The problem involves decoding a string that follows a specific encoding rule: k[encoded_string], where the encoded_string inside the square brackets is repeated exactly k times. Your task is to decode the string and return the decoded string.
#18. Decode String
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.
#19. Longest Consecutive Sequence
You are given two linked lists, each representing a non-negative integer. Add the two numbers and return the sum as a linked list.
#20. Add Two Numbers