Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 1.05 KB

Problem Solving Patterns.md

File metadata and controls

30 lines (19 loc) · 1.05 KB

Problem Solving Patterns

📌 1. Frequency Counter

  • Using objects or sets to collect values/frequencies of values
  • Avoid the need for nested loops or O(n2) operations with arrays / strings.

📌 2. Multiple Pointers

  • Creating pointers or values that correspond to an index or position
  • moving towards the beginning, or the end or middle based on a certain condition
  • Searching for a pair of values or Something that meets a condition

📌 3. Sliding Window

  • Creating a window which can either be an array or number from one position to another.
  • the window either increases or closes, and a new window is created (depending on a certain condition)
  • Useful for keeping track of a subset of data that is continuous in some way.

📌 4. Divide and Conquer

  • Dividing a big data set(array, string, linked list, tree) into smaller chunks
  • Repeating a process with a subset of data
  • Approach on many algorithm (e.g. binary search, merge sort, quicksort)

📌 5. Dynamic Programming

📌 6. Greedy Algorithms

📌 7. Backtracking