Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 891 Bytes

File metadata and controls

29 lines (21 loc) · 891 Bytes

LeetCode Data Structures and Algorithms Crash Course

This repository contains notes and examples for the LeetCode Data Structures and Algorithms Crash Course.

Data Structure

Arrays and strings

  1. Two pointers Approach:
    • Solve an array problem in O(n) time complexity.
  2. Sliding Window Approach:
    • Solve finding a valid (longest/smallest) subarray/substring in O(n) time complexity.
    • Also, find number of valid sub-arrays.
  3. Prefix Sum:
    • Only used for array of numbers(int/float).
    • Used when the problem involves sum of sub-arrays.

Important Tip:

Hashing

  1. Checking for the existence:
    • Anytime you find your algorithm running if ... in ..., use hash map or set
  2. Counting/Frequency:
    • Anytime you want to count something think of a hash map or a set.

Stacks and queues

Algorithms

Dynamic Programming