# 🔥 How to solve algorithm problems and thought process

As I have learned and practiced solving algorithm and data-structure problems, I'm looking for `general guidelines` to show the general thought process to find how to solve the algorithms and data-structure problems.

## 🍀 Consider the algorithm according to the input size

• `~ 20` : `O(2^n)`
• `~1000` : `O(n^2)`
• `nested for loop` can be used.
• `~10^5` : `O(n logn)`
• Hash map
• A two pointers implementation like sliding window
• Monotonic stack
• Binary search
• Heap
• A combination of any of the above
• `~10^9` : `O(logn)`

## 🔥 [object Object] or [object Object] related problems

It should be continuous.

## 🔥 [object Object] related problem

It can be dis-continuous.

## 🔥 Problem describes what to do exactly, but large data

• Usually, it won't work just do what you are told.
• You should FIND `pattern` or `algorithm` to calculate it in more faster way.

#### 🗒️ Typical problems

``````Starting from left to right, remove the first number and every other number afterward until you reach the end of the list.
Repeat the previous step again, but this time from right to left, remove the rightmost number and every other number from the remaining numbers.
Keep repeating the steps again, alternating left to right and right to left, until a single number remains.
``````

## ✨ From [object Object]

#### 💡 How to solve it

1. Understand the problem
2. Make a plan
3. Execute the plan
4. Evaluate the result

#### 💡 How to solve it with [object Object]

• Decomposition
• the opposite of composition
• breaking a problem down into smaller parts
• Pattern recognition
• Where have I seen `this` or `something like it` before ?
• Abstraction
• Once we recognize patterns, we can
• remove the details.
• form abstractions.
• Algorithm design