1. Next Permutationhistorical

    Implement a function that obtains the next permutation. The algorithm must rearrange the given sequence of numbers into the next lexicographically greater permutation.

  2. Permutationshistorical

    Given a sequence of distinct numbers, return all possible permutations.

  3. Subsetshistorical

    Given an integer array nums whose elements are all distinct, return all possible subsets (the power set).

  4. Unique Pathshistorical

    A robot starts at the top-left corner of an m × n grid and can move only down or right. Count the paths to the bottom-right corner.

  5. Number of Islandshistorical

    Given a 2D grid consisting of '1' (land) and '0' (water), calculate the number of islands in the grid.

  6. Maximal Squarehistorical

    In a 2D matrix consisting of '0' and '1', find the largest square containing only '1' and return its area.

  7. Partition Equal Subset Sumhistorical

    Given a non-empty array containing only positive integers, determine whether the array can be partitioned into two subsets whose sums are equal.

  8. Perfect Squareshistorical

    Given a positive integer n, find several perfect-square numbers (such as 1, 4, 9, 16, ...) whose sum equals n. You need to minimize the number of perfect squares used.

  9. Target Sumhistorical

    Assign a plus or minus sign to each number in a nonnegative integer array and count the assignments whose sum equals the target S.

  10. Combination Sumhistorical

    Given an array candidates containing no duplicate elements and a target number target, find all combinations of numbers in candidates whose sum equals target.

  11. Coin Changehistorical

    Given coins of different denominations and a total amount, write a function to compute the minimum number of coins needed to make up that amount. If no combination of coins can make up the amount, return -1.

  12. Burst Balloonshistorical

    Each balloon carries a number, and bursting it earns points based on its neighbors. Choose a bursting order that maximizes the total score.

  13. House Robberhistorical

    You are a professional robber planning to rob houses along a street. Each house contains some cash. The only constraint is that adjacent houses have connected security systems, and the alarm will automatically trigger if two adjacent houses are broken into on the same night.

  14. Best Time to Buy and Sell Stock with Cooldownhistorical

    Given daily stock prices, find the maximum trading profit when selling a stock requires a one-day cooldown before buying again.

  15. Minimum Path Sumhistorical

    Given an m x n grid of non-negative integers, find a path from the top-left corner to the bottom-right corner such that the sum of the numbers along the path is minimized.

  16. Longest Increasing Subsequencehistorical

    Given an integer array nums, find the length of the longest strictly increasing subsequence.

  17. Jump Gamehistorical

    Each element of a nonnegative integer array gives the maximum jump length from that position. Determine whether the last position is reachable.

  18. Maximum Product Subarrayhistorical

    Given an integer array nums, find the contiguous subarray with the largest product (the subarray contains at least one number) and return that product.

  19. Maximum Subarrayhistorical

    Given an integer array nums, find the contiguous subarray with the largest sum (the subarray contains at least one element) and return its sum.

  20. First Missing Positivehistorical

    Given an unsorted integer array nums, find the smallest positive integer that does not appear in the array.

  21. 3Sumhistorical

    Given an array nums containing n integers, determine whether there are three elements a, b, and c such that a + b + c = 0. Find all unique triplets whose sum is 0.

  22. Find the Duplicate Numberhistorical

    Given n + 1 integers whose values range from 1 to n, find the repeated number.

  23. Two Sumhistorical

    Given an integer array, find two numbers in the array whose sum equals the target value. The twoSum function should return the indices of these two numbers (index1, index2), with index1 < index2.

  24. Find All Numbers Disappeared in an Arrayhistorical

    An array of length n contains values from 1 to n, some once and some twice. Find the values in this range that do not appear in the array.

  25. Subarray Sum Equals Khistorical

    Given an integer array and an integer k, find the number of contiguous subarrays whose sum equals k.

  26. Longest Consecutive Sequencehistorical

    Given an unsorted integer array nums, find the length of the longest sequence of consecutive numbers. The elements do not need to be contiguous in the original array.

  27. Binary Search Upper Boundhistorical

    Implement binary search on an ascending array that may contain duplicate values. Return the position of the first value greater than or equal to the target.

  28. Find First and Last Position of Element in Sorted Arrayhistorical

    Given an integer array nums sorted in ascending order and a target value target, find the starting and ending positions of the target value in the array.

  29. Binary Search Upper Boundhistorical

    Implement binary search on an ascending array that may contain duplicate values. Return the position of the first value greater than or equal to the target.

  30. Find First and Last Position of Element in Sorted Arrayhistorical

    Given an integer array nums sorted in ascending order and a target value target, find the starting and ending positions of the target value in the array.

  31. Search in Rotated Sorted Arrayhistorical

    Given a rotated sorted array whose rotation count is unknown in advance (for example, 0 1 2 4 5 6 7 may become 4 5 6 7 0 1 2). Search for the given target value in the array.

  32. Search in Rotated Sorted Arrayhistorical

    Given a rotated sorted array whose rotation count is unknown in advance (for example, 0 1 2 4 5 6 7 may become 4 5 6 7 0 1 2). Search for the given target value in the array.

  33. Merge Two Sorted Arrayshistorical

    Merge two sorted integer arrays A and B into A while preserving order. Assume A has enough space for all elements.

  34. Find Peak Elementhistorical

    A peak element is strictly greater than its neighbors. Find a peak in the given array and return its index.

  35. Find the K-th Largesthistorical

    Given an integer array, use the idea of quicksort to find the K-th largest number in the array.

  36. Binary Searchhistorical

    Given an n-element sorted (ascending) integer array nums and a target value target, write a function to search for target in nums. If the target exists, return its index; otherwise return -1.

  37. Find Minimum in Rotated Sorted Arrayhistorical

    Given a rotated ascending array, find its minimum element.

  38. Square Roothistorical

    Implement the function int sqrt(int x). Compute and return the square root of x, rounded down.

  39. Spiral Matrixhistorical

    Given an m-row, n-column matrix, return all elements of the matrix in clockwise spiral order.

  40. Find Smallest Letter Greater Than Targethistorical

    Given a sorted list of characters letters containing only lowercase English letters, and a target letter target, find the smallest letter in this ordered list that is greater than the target letter.

  41. Trapping Rain Waterhistorical

    Given n non-negative integers representing an elevation map where each bar has width 1, calculate how much rain water can be trapped after raining.

  42. Container With Most Waterhistorical

    Given the heights of vertical lines, choose two lines that form a container with the horizontal axis and maximize its water-holding area.

  43. Queue Reconstruction by Heighthistorical

    Each person is described by their height and the number of people at least as tall ahead of them. Reconstruct the queue from these shuffled descriptions.

  44. Largest Numberhistorical

    Given a group of non-negative integers nums, rearrange the order of each number (each number cannot be split) so that they form the largest integer.

  45. Top K Frequent Elementshistorical

    Given a non-empty integer array, return the k most frequent elements.

  46. Majority Elementhistorical

    Given an array of size n, find its majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times in the array.

  47. Single Numberhistorical

    Given a non-empty integer array, every element appears twice except for one. Find the element that appears only once.

  48. Move Zeroeshistorical

    Given an array nums, write a function to move all 0s to the end of the array while preserving the relative order of the non-zero elements.

  49. Product of Array Except Selfhistorical

    Given an integer array nums of length n, where n > 1, return an output array output where output[i] equals the product of all elements in nums except nums[i].

  50. Sort Colorshistorical

    Given an array with n elements colored red, white, and blue, sort them in place so that elements of the same color are adjacent, in the order red, white, and blue.

  51. Search a 2D Matrixhistorical

    Given a row- and column-sorted matrix and a target value, design an efficient algorithm to determine whether the value is present.

  52. Maximum Product Subarrayhistorical

    Given an integer array nums, find the contiguous subarray with the largest product (the subarray contains at least one number) and return that product.

  53. Subarray Sum Equals Khistorical

    Given an integer array and an integer k, find the number of contiguous subarrays whose sum equals k.

  54. Maximal Squarehistorical

    In a 2D matrix consisting of '0' and '1', find the largest square containing only '1' and return its area.

  55. Daily Temperatureshistorical

    Given a list of daily temperatures, generate a new list where each position contains the minimum number of days you must wait to observe a warmer temperature.

  56. Daily Temperatureshistorical

    Given a list of daily temperatures, generate a new list where each position contains the minimum number of days you must wait to observe a warmer temperature.

  57. Sliding Window Maximumhistorical

    Slide a window of length k across an array from left to right and return the maximum value in each window.

  58. Merge Intervalshistorical

    Given a collection of intervals, merge all overlapping intervals and return the resulting coverage.

  59. Min Stackhistorical

    Design a stack that supports push, pop, and top, and can retrieve the minimum element in constant time.

  60. Sort an Arrayhistorical

    Given an array, write a function that returns the array in sorted order.

  61. Median of Two Sorted Arrayshistorical

    Given two sorted arrays of lengths m and n, find the median of their combined values.

  62. Jump Gamehistorical

    Each element of a nonnegative integer array gives the maximum jump length from that position. Determine whether the last position is reachable.

  63. Shortest Unsorted Continuous Subarrayhistorical

    Given an integer array nums, find a continuous subarray such that sorting only this subarray in ascending order makes the whole array sorted in ascending order.

  64. Best Time to Buy and Sell Stockhistorical

    Given daily stock prices, find the maximum profit from a single purchase followed by a single sale.

  65. Rotate Imagehistorical

    Given an n x n two-dimensional matrix matrix representing an image, rotate the image 90 degrees clockwise.