Showing 469 questions
A special binary string has equal numbers of 0s and 1s, and any prefix has at least as many 1s as 0s. You need to recursively make the lexicographically largest special string possible from a given special binary string.
#1. Special Binary String
You are given a matrix and a series of update operations. Each operation specifies a submatrix that should have all its elements incremented by one. Your goal is to perform all the updates and return the modified matrix.
#2. Increment Submatrices by One
Convert a string into a 32-bit signed integer. Handle leading whitespace, signs, invalid input, and integer overflow according to the rules of the atoi function.
#3. String to Integer (atoi)
The N-Queens problem asks you to place N chess queens on an N×N chessboard so that no two queens threaten each other. Your task is to find all possible distinct solutions for placing the queens.
#4. N-Queens
Find the longest string that is a prefix of all strings in a given array. If no common prefix exists, return an empty string.
#5. Longest Common Prefix
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.
#6. Two Sum
Find all unique triplets in an array that sum to zero. You'll need to consider the potential for duplicate numbers and avoid duplicate triplets in your solution.
#7. 3Sum
Find the median of two sorted arrays. The arrays can be of different sizes, and you should aim for an efficient solution.
#8. Median of Two Sorted Arrays
Find the length of the longest substring within a given string that contains no repeating characters. The substring must be contiguous.
#9. Longest Substring Without Repeating Characters
Write a function that returns the string 'Hello, World!'. This is a classic first coding challenge.
#10. Create Hello World Function
You are given two linked lists, each representing a non-negative integer. Add the two numbers and return the sum as a linked list.
#11. Add Two Numbers
You are given two sorted integer arrays. Merge the second array into the first one, maintaining the sorted order.
#12. Merge Sorted Array
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.
#13. Majority Element
Given a list of words, group together all the anagrams. Anagrams are words that contain the same letters rearranged.
#14. Group Anagrams
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.
#15. Trapping Rain Water
You are climbing a staircase with n steps. Find how many distinct ways you can climb to the top, given that you can climb one or two steps at a time.
#16. Climbing Stairs
Determine if a string containing parentheses is valid. A valid string has matching and properly nested opening and closing parentheses.
#17. Valid Parentheses
Given a set of coin denominations and a target amount, find the minimum number of coins needed to reach that amount. You can assume you have an unlimited supply of each coin type.
#18. Coin Change
You're given daily stock prices. Find the maximum profit you can make by buying and selling the stock once. You must buy before you sell.
#19. Best Time to Buy and Sell Stock
Determine whether an integer is a palindrome. That is, it reads the same forwards and backward.
#20. Palindrome Number