Array

Sum

Product

  • No. 238: Product of Array Except Self: Two times calculation O(n)

Majority

Max Consecutive

  • No. 485: Max Consecutive Ones

  • No. 487: Max Consecutive Ones II https://eugenejw.github.io/2017/08/leetcode-487 (also applicable to 1004)

  • No. 1004: Max Consecutive Ones III

    • O(1) space: moving window

    • time: queue

  • No. 1446: Consecutive Characters (485)

  • No. 1869: Longer Contiguous Segments of Ones than Zeros (485)

  • No. 1784: Check if Binary String Has at Most One Segment of Ones (485)

  • No. 1550: Three Consecutive Odds (485)

  • No. 128: Longest Consecutive Sequence: Hashing

  • No. 829: Consecutive Numbers Sum: calculation O(sqrt(N))

Amplitude

Stock:

Other:

  • No. 189 Rotate Array: Copy; O(1)-tmp memory; Reverse two set and Reverse all

  • No. 632: Smallest Range: K merge sort

  • No. 697: Degree of an Array: Hashmap

Last updated