How to solve a DSA Problem
There can be various alternative ways to solve a problem
The first solution that comes in mind is brute force solution
The most efficient solution that consumes least time and space is called optimized solution
Every problem has a pattern - Figure out the problem belongs to which pattern
Once you have figure out the pattern, for each pattern there are alternative approaches
For each approach, you should know 3 things -
Concept - covered in Volume 2
Data structure - covered in Volume 2
Technique/Strategy - In this Volume we will mainly learn various Strategies and Techniques
Sometimes concepts and techniques are overlapping
Talking about algorithm, Algorithm is a pseudo code/ implementation of a technique. Sometimes you would already be knowing the algorithm as we will also be discussing some common algorithms
Common Data Structure Problem Patterns
Array Reversal / Rotation
Sum of Elements in a range for Q Queries
Given input is Sorted Array
Top/maximum/minimum/closest 'K' Elements among 'n' Elements
Need of trying all permutations and Combinations
Trees and Graphs problems
Maximization and Minimization
Find common substring among a set of Strings
Search/manipulate a bunch of Strings
LinkedList Question without using Extra Space
Common Techniques
prefix sum
carry forward
sliding window
2 pointers
recursion
greedy
fast and slow pointers
islands(matrix traversal)
merge intervals
cyclic sort
two heaps
bitwise xor
topological sort
0/1 knapsack
pallindromic subsequence
longest common substring
In place reversal of Linked List
Modified Binary Search
Subsets
K-way Merge
Topological Sort
Common Algos
Insertion Sort
Selection Sort
Bubble Sort
Merge sort
Quick Sort
Binary Search
Breadth First Search
Depth First Search