Data Structures & Algorithms
237 notes
Some notes are currently available only in Chinese. English translations are shown when available.
- Climbing Stairshistorical
A staircase has n steps, and each move climbs one or two steps. Count the distinct ways to reach the top.
- 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.
- 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.
- 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.
- Find Peak Elementhistorical
A peak element is strictly greater than its neighbors. Find a peak in the given array and return its index.
- Find the K-th Largesthistorical
Given an integer array, use the idea of quicksort to find the K-th largest number in the array.
- 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.
- Find Minimum in Rotated Sorted Arrayhistorical
Given a rotated ascending array, find its minimum element.
- Square Roothistorical
Implement the function int sqrt(int x). Compute and return the square root of x, rounded down.
- Spiral Matrixhistorical
Given an m-row, n-column matrix, return all elements of the matrix in clockwise spiral order.