Data Structures & Algorithms
237 notes
Some notes are currently available only in Chinese. English translations are shown when available.
- 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].
- 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.
- 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.
- Jump Floorhistorical
A frog can jump either 1 step or 2 steps at a time. Find the total number of ways the frog can jump up a staircase with n steps (different orders count as different results).
- Jump Floor IIhistorical
A frog can jump 1 step at a time, 2 steps at a time... or even n steps at a time. Find the total number of ways the frog can jump up a staircase with n steps.
- Fibonacci Sequencehistorical
Given an integer n, output the nth item of the Fibonacci sequence (starting from 0, where the 0th item is 0 and the 1st item is 1).
- Number of 1 Bitshistorical
Given an integer, output the number of 1s in its 32-bit binary representation. Negative numbers are represented using two's complement.
- Integer Power of a Numberhistorical
Given a floating-point number base of type double and an integer exponent of type int, calculate base raised to the power of exponent.
- Number of Digit 1 Occurrenceshistorical
Given an integer n, count how many times the digit 1 appears in all integers from 1 through n.
- 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.