A repo for my submissions to online coding and competitive programming platforms like CodeChef, CodeForces, Geeks for Geeks, HackerRank, LeetCode, etc.
Below are some problems that require a revisit / are a bit tricky / are some core concepts.
(See .java or .swift files for code and explanation)
- Dijkstra's Algorithm
- Prims's/Kruskal's Algorithm
- Bellman-Ford/Floyd-Warshall Algorithm to detect negative weight cycle in a graph
- Backtracking
- N-Queen Problem
- Rat in a Maze
- Travelling Salesman Problem - using DFS
- Knight's Tour - using BFS
- Flood fill Algorithm
- Smallest Multiple With 0 and 1
- Quadruplets with a given sum - using Two Pointers Technique
- Triplets with sum less than X
- Maximum array sum without adjacent elements - using Dynamic Programming with Recursion
- Merge two sorted arrays in constant space
- Zero Sum Subarrays
- Search element in a sorted, but rotated, array
- Allocate minimum number of pages - Binary Search the Answer
- Randomised Quick Sort
- Heap Sort
Sorting Algorithms | Time Complexities | ||
---|---|---|---|
Best | Average | Worst | |
Selection Sort | Ω(n2) | θ(n2) | O(n2) |
Bubble Sort | Ω(n) | ||
Insertion Sort | |||
Quick Sort | Ω(nlog(n)) | θ(nlog(n)) | |
Heap Sort | O(nlog(n)) | ||
Merge Sort |
- 0 - 1 Knapsack Problem
- Coin Change Problem
- Matrix Chain Multiplication
- Word Break - approach similar to MCM
- Edit Distance
- Longest Increasing Subsequence
- Longest Common Substring
- Count Palindromic Subsequences
- Maximum sum increasing subsequence
- Largest square submatrix with all 1s
- Best Time to Buy and Sell Stock III - at most 2 transactions allowed
- Best Time to Buy and Sell Stock IV - using bottom-up dp
- Evaluate Expression to True