Data Structures & Algorithms
237 notes
Some notes are currently available only in Chinese. English translations are shown when available.
- 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.
- 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.
- 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.
- 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.
- 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.
- String Permutationshistorical
Given a string, print all permutations of its characters in lexicographic order. For example, given the string abc, print all strings formed by a, b, and c in lexicographic order: abc, acb, bac, bca, cab, and cba.
- Top K Frequent Elementshistorical
Given a non-empty integer array, return the k most frequent elements.
- 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.
- Single Numberhistorical
Given a non-empty integer array, every element appears twice except for one. Find the element that appears only once.
- 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.