- Arrays
- 2 Sum
- Time Complexity - O(n)
- Space Complexity - O(n)
- Median of 2 sorted arrays
- Time Complexity - O(log(min(m,n))
- Space Complexity - O(1)
- Container With Most Water
- Time Complexity - O(n)
- Space Complexity - O(1)
- 3 Sum
- Time Complexity - O(n^2)
- Space Complexsity - O(1)
- 3 Sum Closest
- Time Complexity - O(n^2)
- Space Complexity - O(1)
- 4 Sum
- Time Complexity - O(n^3)
- Space Complexity - O(1)
- Remove Duplicates Sorted Array
- Time Complexity - O(n)
- Space Complexity - O(1)
- Remove Elements In Place
- Time Complexity - O(n)
- Space Complexity - O(1)
- Next Permutation Lexicographycally
- Time Complexity - O(n)
- Space Complexity - O(1)
- Search In Rotated Sorted Array
- Time Complexity - O(logn)
- Space Complexity - O(1)
- Find First And Last Index In Sorted Array
- Time Complexity - O(logn)
- Space Complexity - O(1)
- Search Insert Position
- Time Complexity - O(logn)
- Space Complexity - O(1)
- Combination Sum With Repetition
- Time Complexity - O(n^(n/2))
- Space Complexisty -
- 2 Sum
- Sorting
- Selection Sort
- In place
- Not stable
- Best case - O(1/2 * n^2)
- Average Case - O(1/2 * n^2)
- Worst Case - O(1/2 * n^2)
- Insertion Sort
- In Place
- Stable
- Best Case - O(n)
- Average Case - O(1/4 * n^2)
- Worst Case - O(1/2 * n^2)
- Use for small or partially sorted arrays
- Bubble Sort
- In Place
- Stable
- Best Case - O(n)
- Average Case - O(1/2 * n^2)
- Worst Case - O(1/2 * n^2)
- Rarely used, insertion sort can be preferred
- Shell Sort
- In Place
- Stable
- Best Case - O(nlogn)
- Average - O(nlogn)
- Worst - O(n^2)
- Merge Sort
- Not In Place
- Stable
- Best Case - O((1/2)(nlogn))
- Average Case - O(nlogn)
- Worst Case - O(nlogn)
- Space complexity - O(n)
- Quick Sort
- In place
- Not Stable
- Best Case - O(nlogn)
- Average Case - O(nlogn)
- Worst Case - O(n^2)
- Space Complexity - O(1)
- Heap Sort
- In place
- Not Stable
- Best Case - O(n)
- Average Case - O(nlogn)
- Worst Case - O(nlogn)
- Selection Sort
- Searching
- Sequential Search
- Worst Case
- Search - O(n)
- Insert - O(n)
- Delete - O(n)
- Average Case
- Search - O(n)
- Insert - O(n)
- Delete - O(n)
- Worst Case
- Binary Search
- Worst Case
- Search - O(log(n))
- Insert - O(n)
- Delete - O(n)
- Average Case
- Search - O(log(n))
- Insert - O(n)
- Delete - O(n)
- Worst Case
- Hash Table
- Worst Case
- Search - O(n)
- Insert - O(n)
- Delete - O(n)
- Average Case (Provided the hash function is uniform)
- Search - O(1)
- Insert - O(1)
- Delete - O(1)
- Worst Case
- Binary Search Tree
- Worst Case
- Search - O(n)
- Insert - O(n)
- Delete - O(n)
- Average Case
- Search - O(logn)
- Insert - O(logn)
- Delete - sqrt(n)
- Worst Case
- Sequential Search
- Graph Processing 1.
dineshsy / problem-solving Goto Github PK
View Code? Open in Web Editor NEWThis project forked from pushparajkvp/problem-solving
Various CS problems and solution