- Find all topic wise questions in different folders:)
- From Basic to Hard level questions under each topic
- Problems are from Leetcode and Geeksforgeeks website.
- Separate folders for CP. All Solutions are not optimised
Data Structure | Add/Insert | Remove/Delete | Access/Get | Search/Contains | Space Complexity |
---|---|---|---|---|---|
Array | O(n) |
O(n) |
O(1) |
O(n) |
O(n) |
Set | O(logn) |
O(logn) |
- |
O(logn) |
O(n) |
Unordered Set | O(1)Average O(n)Worst |
O(1)Average O(n)Worst |
- |
O(1)Average O(n)Worst |
O(n) |
Map | O(logn) |
O(logn) |
- |
O(logn) |
O(n) |
Unordered Map | O(1)Average O(n)Worst |
O(1)Average O(n)Worst |
- |
O(1)Average O(n)Worst |
O(n) |
Stack | O(1) |
O(1) |
O(n) |
O(n) |
O(n) |
Queue | O(1) |
O(1) |
O(n) |
O(n) |
O(n) |
Binary Search Tree | O(log n) |
O(log n) |
O(log n) |
O(log n) |
O(n) |
Binary Min Heap | O(log n) |
O(log n) |
O(1) |
O(n) |
O(n) |
Binary Max Heap | O(log n) |
O(log n) |
O(1) |
O(n) |
O(n) |
Sort Algorithm | Best | Average | Worst | Space Complexity |
---|---|---|---|---|
Selection Sort | O(n^2) |
O(n^2) |
O(n^2) |
O(1) |
Bubble Sort | O(n^2) |
O(n^2) |
O(n^2) |
O(1) |
Insertion Sort | O(n) |
O(n^2) |
O(n^2) |
O(1) |
Quick Sort | O(n logn) |
O(n logn) |
O(n^2) |
O(logn) |
Merge Sort | O(n logn) |
O(n logn) |
O(n logn) |
O(n) |
Counting Sort | O(n+k) |
O(n+k) |
O(n+k) |
O(k) |
Tim Sort | O(n) |
O(n logn) |
O(n logn) |
O(n) |
Heap Sort | O(n long) |
O(n logn) |
O(n logn) |
O(1) |
Shell Sort | O(n) |
O((n logn)^2) |
O((n logn)^2) |
O(1) |
Bucket Sort | O(n+k) |
O(n+k) |
O(n^2) |
O(1) |
Radix Sort | O(nk) |
O(nk) |
O(nk) |
O(n+k) |
This will be the repository for C++ topic wise questions, practice questions and DSA :)
- Minimum swaps and K together
- Factorials of large numbers
- Longest Palindrome in a String
- Longest Prefix Suffix
- count and say
- Chocolate Distribution Problem
- Median of Two sorted arrays
- Merge Without Extra Space
- Sort by Set Bit Count
- Three way partitioning
- Count Occurences of Anagrams
- Length of the longest substring
- Longest Subarray with atmost K Even elements
- Max Sum Subarray of size K
- Maximum sum of subarray less than or equal to x
- Subarray with given sum
- Value equal to index value
- First and last occurrences of x
- Find a pair with a given difference
- Search in Rotated Sorted Array
- Find common elements In 3 sorted arrays
- Longest Equal Prefix
- Max value after m range operation
- Equilibrium Point
- Mean of range in array
- Nitika and her queries
- Union of two arrays
- Count pairs with given sum
- Longest consecutive subsequence
- Array Subset of another array
- First Missing Positive
- Find All Numbers Disappeared in an Array
- Container With Most Water
- Best Time to Buy and Sell Stock
- Valid Sudoku
Realized that my knowledge of dp is not sufficient to solve problems of DP. So started Aditya Verma's DP Playlist.
Felt that right now my level is not enough good to understand DP so skiped it for latter and started LinkedList.
- Smallest window in a string containing all the characters of another string
- Search a 2D Matrix
- Find the string in grid
- Determinant of a Matrix
- Boolean Matrix
- Make Matrix Beautiful
- Reverse a Linked List in groups of given size
- Detect Loop in linked list
- Remove loop in Linked List
- Find length of Loop
- Rotate a Linked List
- Remove duplicate element from sorted Linked List
- Remove duplicates from an unsorted linked list
- Add 1 to a number represented as linked list
- Add two numbers represented by linked lists
- Intersection of two sorted Linked lists
- Intersection Point in Y Shapped Linked Lists
- Middle of the Linked List
- Check If Circular Linked List
- Split a Circular Linked List into two halves
- Check if Linked List is Palindrome
- Reverse a Doubly Linked List
- Given a linked list of 0s, 1s and 2s, sort it.
- Clone a linked list with next and random pointer
- Multiply two linked lists
- Delete nodes having greater value on right
- A - Shortest Path with Obstacle
- B - Alphabetical Strings
- C - Pair Programming
- D - Co-growing Sequence
- Segregate even and odd nodes in a Link List
- Nth node from end of linked list
- Swap Kth nodes from ends
- Pairwise swap of nodes in LinkeList
- Merge K sorted linked lists
- Number of 1 Bits
- Non Repeating Numbers
- Bit Difference
- Power of 2
- Find position of set bit
- Power Set
- Letter Combinations of a Phone Number
- Find All Anagrams in a String
- Partition Labels
- String to Integer (atoi)
- Median in a row-wise sorted Matrix
- Implement two stacks in an array
- Parenthesis Checker
- Reverse a string using Stack
- Next Greater Element
- The Celebrity Problem
- Evaluation of Postfix Expression
- Maximum Rectangular Area in a Histogram
- Delete middle element of a stack
- Stack using two queues
- Queue using two Stacks
- Queue Reversal
- Reverse First K elements of Queue
- First negative integer in every window of size k
- Count the Reversals
- Maximum of all subarrays of size k
- Product array puzzle
- Search a 2D Matrix II
- Intersection of Two Arrays II
Learned about Binary Trees and implemented basic functions of Binary Trees
- Level order traversal
- Reverse Level Order Traversal
- Height of Binary Tree
- Diameter of Binary Tree
- Left View of Binary Tree
- Right View of Binary Tree
- ZigZag Tree Traversal
- Check for Balanced Tree
- Binary Tree to DLL
- Transform to Sum Tree
- Construct Tree from Inorder & Preorder
- Sum Tree
- Leaf at same level
- Check Mirror in N-ary tree
- Sum of the Longest Bloodline of a Tree
- Lowest Common Ancestor in a Binary Tree
- Min distance between two given nodes of a Binary Tree
Learned basics of Binary Search Tree and Implemented its basic functions
- Count total set bits
- Duplicate subtree in Binary Tree
- Duplicate Subtrees
- Delete Node in a BST
- Minimum element in BST
- Predecessor and Successor
- Check for BST
- Populate Inorder Successor for all nodes
- Lowest Common Ancestor in a BST
Implemented Min Heap in C++.
While solving problems I realized that my knowledge is not sufficient so started to learn graph from CodeNCode.
- Vertical Traversal of Binary Tree
- Find Common Nodes in two BSTs
- Find the Closest Element in BST
- Convert Level Order Traversal to BST
- Choose and Swap
- Shop in Candy Store
- Maximize sum after K negations
- Nodes at given distance in binary tree