Skip to content

rohillanishant/DSA-Cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DSA SUPREME QUESTIONS WEEK WISE
Q QUESTION T.C S.C LINK
WEEK 3 ARRAYS & VECTORS
1 Sort Colors(Leetcode Q75) https://leetcode.com/problems/sort-colors/
2 Move All Negative Numbers to Left of Array n https://github.com/rohillanishant/DSA-Cpp/blob/master/ArrayQues/MoveNegativeToLeft.cpp
3 Find Duplicate Number (LeetCode Q287) n https://leetcode.com/problems/find-the-duplicate-number/
4 Missing Elements from an array With Duplicates n https://github.com/rohillanishant/DSA-Cpp/blob/master/ArrayQues/FindMissing.cpp
5 First Repeating Element n https://github.com/rohillanishant/DSA-Cpp/blob/master/ArrayQues/FstRptElmnt.cpp
6 Common Elements in 3 Sorted Array n1+n2+n3 https://practice.geeksforgeeks.org/problems/common-elements1132/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article
7 Wave Print A Matrix mn https://github.com/rohillanishant/DSA-Cpp/blob/master/2DArray/WavePrintMatrix.cpp
8 Spiral Print A Matrix mn https://github.com/rohillanishant/DSA-Cpp/blob/master/2DArray/SpiralOrder.cpp
9 Factorial of a Large Number
WEEK 4 SEARCHING & SORTING
1 Linear Search n 1 https://github.com/rohillanishant/DSA-Cpp/blob/master/Searching.cpp
2 Binary Search logn logn https://github.com/rohillanishant/DSA-Cpp/blob/master/BinarySearch/BinarySearch.cpp
3 First & Last Occurrence (LeetCode Q34) logn https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/
4 Peak Index in Mountain Array (LeetCode Q852) logn https://leetcode.com/problems/peak-index-in-a-mountain-array/
5 Find Missing Element in range 1 to n
6 Find Pivot Element
7 Search in Rotated & Sorted Array(LeetCode Q33) logn https://leetcode.com/problems/search-in-rotated-sorted-array/
8 Square Root using Binary Search https://github.com/rohillanishant/DSA-Cpp/blob/master/BinarySearch/SquareRoot.cpp
9 Binary Search in 2d Matrix https://github.com/rohillanishant/DSA-Cpp/blob/master/BinarySearch/BinarySearchMatrix.cpp
10 Search in Nearly/Almost Sorted Array https://github.com/rohillanishant/DSA-Cpp/blob/master/BinarySearch/SearchNearlySortedArray.cpp
11 Divide using binary search https://github.com/rohillanishant/DSA-Cpp/blob/master/BinarySearch/Divide.cpp
12 Find element with odd occurence https://github.com/rohillanishant/DSA-Cpp/blob/master/BinarySearch/OddOccurence.cpp
13 Selection Sort https://github.com/rohillanishant/DSA-Cpp/blob/master/SelectionSort.cpp
14 Bubble Sort https://github.com/rohillanishant/DSA-Cpp/blob/master/BubbleSort.cpp
15 Insertion Sort https://github.com/rohillanishant/DSA-Cpp/blob/master/InsertionSort.cpp
1 K-diff Pairs in an Array (LeetCode Q532) https://leetcode.com/problems/k-diff-pairs-in-an-array/
2 Find K Closest Elements (LeetCode Q658) https://leetcode.com/problems/find-k-closest-elements/
3 Exponential Search https://github.com/rohillanishant/DSA-Cpp/blob/master/BinarySearch/ExponentialSearch.cpp
4 Book Allocation Problem https://practice.geeksforgeeks.org/problems/allocate-minimum-number-of-pages0937/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article
5 Painter Partition Problem https://practice.geeksforgeeks.org/problems/the-painters-partition-problem1535/1
6 Aggressive Cows https://practice.geeksforgeeks.org/problems/aggressive-cows/1
7 EKO SPOJ https://www.spoj.com/problems/EKO/
https://github.com/rohillanishant/DSA-Cpp/blob/master/BinarySearch/EkoSpoj.cpp
8 PRATA SPOJ https://www.spoj.com/problems/PRATA/
https://github.com/rohillanishant/DSA-Cpp/blob/master/BinarySearch/PrataSpoj.cpp
WEEK 5 CHAR ARRAYS & STRINGS
1 Length of a Char Array https://github.com/rohillanishant/DSA-Cpp/blob/master/CharArrays/LengthCharArray.cpp
2 Getline USE https://github.com/rohillanishant/DSA-Cpp/blob/master/CharArrays/getline.cpp
3 Reverse of a Char Array https://github.com/rohillanishant/DSA-Cpp/blob/master/CharArrays/Reverse.cpp
4 Replace all spaces by @ https://github.com/rohillanishant/DSA-Cpp/blob/master/CharArrays/Replace.cpp
5 Palindrome https://github.com/rohillanishant/DSA-Cpp/blob/master/CharArrays/Palindrome.cpp
6 UpperCase to LowerCase https://github.com/rohillanishant/DSA-Cpp/blob/master/CharArrays/UpperToLowerCase.cpp
7 LowerCase to Uppercase https://github.com/rohillanishant/DSA-Cpp/blob/master/CharArrays/LowerToUpperCase.cpp
8 String Basic Functions https://github.com/rohillanishant/DSA-Cpp/blob/master/String/Functions.cpp
9 Remove All Adjacent Duplicates In String (1047) https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/description/
10 Remove All Occurrences of a substring (1910) https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/description/
11 Valid palindrome II (680) https://leetcode.com/problems/valid-palindrome-ii/
12 Minimum Time Difference (539) https://leetcode.com/problems/minimum-time-difference/
13 Palindromic Substring (647) https://leetcode.com/problems/palindromic-substrings/
1 Valid Anagram (242) m+n https://leetcode.com/problems/valid-anagram/
2 Reverse Only Letters (917) https://leetcode.com/problems/reverse-only-letters/description/
3 Longest Common Prefix (14) mn https://leetcode.com/problems/longest-common-prefix/
4 Reverse Vowels of a String (345) https://leetcode.com/problems/reverse-vowels-of-a-string/description/
5 Isomorphic Strings (205) https://leetcode.com/problems/isomorphic-strings/description/
6 Reorganize String (767) https://leetcode.com/problems/reorganize-string/description/
7 Group Anagrams (49) https://leetcode.com/problems/group-anagrams/description/
8 Longest Palindromic Substring (5) https://leetcode.com/problems/longest-palindromic-substring/description/
9 Find the Index of the First Occurrence in a String (28) https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/
10 String to Integer (atoi) (8) https://leetcode.com/problems/string-to-integer-atoi/
11 String Compression (443) https://leetcode.com/problems/string-compression/description/
12 Integer to Romans (12) https://leetcode.com/problems/integer-to-roman/
13 Zig Zag Conversion https://leetcode.com/problems/zigzag-conversion/
14 Largest Number (179) https://leetcode.com/problems/largest-number/
WEEK 6 BASIC MATHS & POINTERS
1 Pointers
2 Count Primes (204) [using Sieve of Eratosthenes] n(log(logn)) https://leetcode.com/problems/count-primes/description/
3 GCD/HCF https://practice.geeksforgeeks.org/problems/gcd-of-two-numbers3459/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article
4 Fast Exponent log b https://github.com/rohillanishant/DSA-Cpp/blob/master/FastExponent.cpp
5 Modular Exponentiation of large numbers log b https://practice.geeksforgeeks.org/problems/modular-exponentiation-for-large-numbers5537/1
6 Prime No in Range using Segmented Sieve n(log(logn)) https://github.com/rohillanishant/DSA-Cpp/blob/master/SieveOfEratosthenes/SegmentedSieve.cpp
7 Product of Primes n(log(logn)) https://practice.geeksforgeeks.org/problems/product-of-primes5328/1
WEEK 7 RECURSION
1 Climbing Stairs (70) https://leetcode.com/problems/climbing-stairs/
2 Array Print https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/ArrayPrint.cpp
3 Find Maximum Element in Array using Recursion https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/MaxElementinArray.cpp
4 Search Key in String using Recursion https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/SearchCharInString.cpp
5 Print All Digits of a Number https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/PrintAllDigits.cpp
6 Check if array is Sorted https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/isSortedArray.cpp
7 Binary Search https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/BinarySearch.cpp
8 Print All Subsequences https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/Subsequence.cpp
9 Minimum no of elements whose sum=target https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/TargetSum.cpp
10 Cut into Segments https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/CutIntoSegments.cpp
11 Maximum sum by using non adjacent elements https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/MaxSumNonAdjacentElements.cpp
1 Last Occurrence of a Char in String n https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/LastOccurenceinString.cpp
2 Reverse a String n https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/ReverseString.cpp
3 Add Strings (415) n https://leetcode.com/problems/add-strings/description/
4 Palindrome n https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/Palindrome.cpp
5 Remove All Occurrences of a Substring nm https://leetcode.com/problems/remove-all-occurrences-of-a-substring/submissions/991734158/
6 Print All Subarrays n^2
7 Best time to buy and sell stocks n https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/
8 House Robber (198) 2^n https://leetcode.com/problems/house-robber/
9 Integer to English Words (273) log10(N) https://leetcode.com/problems/integer-to-english-words/description/
10 WildCard Matching (44) 2^n https://leetcode.com/problems/wildcard-matching/
11 Perfect Squares (279) n^n https://leetcode.com/problems/perfect-squares/
12 Minimum Cost For Tickets(983) 3^n https://leetcode.com/problems/minimum-cost-for-tickets/
13 Number of Dice Rolls With Target Sum (1155) k^n https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/
WEEK 8 DnC & Backtracking
1 Merge Sort (DnC) nlogn n https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/MergeSort.cpp
2 Quick Sort (DnC) nlogn(worst case- n^2) https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/QuickSort.cpp
3 Permutations (Backtracking) n! n https://github.com/rohillanishant/DSA-Cpp/blob/master/Backtracking/Permutations.cpp
4 Rat in a maze (Backtracking) 4^(row+col) row*col https://practice.geeksforgeeks.org/problems/rat-in-a-maze-problem/1
5 N-Queens (Backtracking) (51) worst-n*n(avg-n!) n^2 https://leetcode.com/problems/n-queens/
6 Generate paranthesis (backtracking) (22) https://leetcode.com/problems/generate-parentheses/description/
7 Letter Combinations of a Phone Number (Backtracking) 4^n 4^n https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/
8 Sudoku Solver (Backtracking) (37) 9^(row+col) row*col https://leetcode.com/problems/sudoku-solver/description/
1 Count Inversions : Merge Sort nlogn n https://www.hackerrank.com/challenges/ctci-merge-sort/problem?isFullScreen=true
2 In Place Merge Sort nlogn 1 https://github.com/rohillanishant/DSA-Cpp/blob/master/Recursion/InPlaceMergeSort.cpp
3 Max Sub Array Sum (53) nlogn logn https://leetcode.com/problems/maximum-subarray/description/
4 QuickSort (last element as pivot) (2nd Method) nlogn(worst case- n^2) https://practice.geeksforgeeks.org/problems/quick-sort/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article
5 Combination Sum (39) https://leetcode.com/problems/combination-sum/description/
6 Combination Sum II (40) https://leetcode.com/problems/combination-sum-ii/description/
7 Permutations II (47) https://leetcode.com/problems/permutations-ii/
8 Beautiful Arrangment (526) https://leetcode.com/problems/beautiful-arrangement/description/
9 Distribute Repeating Integers (1655) https://leetcode.com/problems/distribute-repeating-integers/
Linked Lists
1 Singly Linked List https://github.com/rohillanishant/DSA-Cpp/blob/master/LinkedList/LinkedList.cpp
2 Doubly Linked List https://github.com/rohillanishant/DSA-Cpp/blob/master/LinkedList/DoublyLinkedList.cpp
3 Reverse of Linked List n 1
4 Middle of Linked List n 1 https://github.com/rohillanishant/DSA-Cpp/blob/master/LinkedList/MiddleElement.cpp
5 Reverse Nodes in K-Groups (25) n 1 https://leetcode.com/problems/reverse-nodes-in-k-group/
6 Reverse Nodes in Even length Groups (2074) n 1 https://leetcode.com/problems/reverse-nodes-in-even-length-groups/description/
(Not in supreme,but same as above)
7 Detect Loop Start Point (142) n 1 https://leetcode.com/problems/linked-list-cycle-ii/
8 Palindrome Linked List (234) n 1 https://leetcode.com/problems/palindrome-linked-list/description/
9 Remove Duplicates from Sorted List (83) n 1 https://leetcode.com/problems/remove-duplicates-from-sorted-list/description/
10 Remove Duplicates from UnSorted List n 1 https://practice.geeksforgeeks.org/problems/remove-duplicates-from-an-unsorted-linked-list/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article
11 Sort 0's 1's and 2's in linked list n 1 https://practice.geeksforgeeks.org/problems/given-a-linked-list-of-0s-1s-and-2s-sort-it/1
12 Add two numbers (Reverse) (2) n 1 https://leetcode.com/problems/add-two-numbers/
13 Add two numbers n 1 https://practice.geeksforgeeks.org/problems/add-two-numbers-represented-by-linked-lists/1?utm_source=gfg&utm_medium=article&utm_campaign=bottom_sticky_on_article
1 Print/Remove Nth Node from End (19) n 1 https://leetcode.com/problems/remove-nth-node-from-end-of-list/description/
2 Intersection of two linked lists (160) n 1 https://leetcode.com/problems/intersection-of-two-linked-lists/submissions/
3 Merge two Sorted Lists (21) n 1 https://leetcode.com/problems/merge-two-sorted-lists/
4 Sort List (148) nlogn n https://leetcode.com/problems/sort-list/description/
5 Flattening a Linked List n 1 https://www.geeksforgeeks.org/problems/flattening-a-linked-list/1
6 Copy List with Random Pointer (138) n 1 https://leetcode.com/problems/copy-list-with-random-pointer/description/
7 Rotate List (61) n 1 https://leetcode.com/problems/rotate-list/
8 Delete N nodes after M nodes in a list n n https://www.geeksforgeeks.org/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/1
9 Find Min & Max Nodes Between Critical Points (2058) n 1 https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/
10 Merge Nodes in Between Zeros (2181) n 1 https://leetcode.com/problems/merge-nodes-in-between-zeros/description/
Stack
1 Stack https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/Stack.cpp
2 Stack Using Array https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/StackUsingArray.cpp
3 Stack Using Linked List https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/StackUsingLinkedList.cpp
4 Double Stack Using Array https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/DoubleStackUsingArray.cpp
5 Reverse String n n https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/ReverseString.cpp
6 Middle Element in Stack n n https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/MiddleElement.cpp
7 Insert top element at bottom n n https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/InsertAtBottom.cpp
8 Reverse Stack n^2 n https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/Reverse.cpp
9 Valid Paranthesis (20) n n https://leetcode.com/problems/valid-parentheses/description/
10 Sort Stack n^2 n https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/Sort.cpp
11 Check Redundant Brackets n n https://www.codingninjas.com/studio/problems/redundant-brackets_975473
12 Min Stack (155) 1 1 https://leetcode.com/problems/min-stack/
13 Longest Valid Parentheses n n https://leetcode.com/problems/longest-valid-parentheses/description/
14 Next Smaller Element n n https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/NextSmallerElement.cpp
15 Previous Smaller Element n n https://github.com/rohillanishant/DSA-Cpp/blob/master/Stack/PreviousSmallerElement.cpp
16 Largest Rectangle in Histogram (84) n n https://leetcode.com/problems/largest-rectangle-in-histogram/
1 Remove All Adjacent Duplicates In String (1047) n n https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/description/
2 Minimum Bracket Reversal / Count the Reversals n n https://www.geeksforgeeks.org/problems/count-the-reversals0401/1
3 Next Greater Element in LL (1019) n n https://leetcode.com/problems/next-greater-node-in-linked-list/description/
4 Celebrity Problem n n https://www.geeksforgeeks.org/problems/the-celebrity-problem/1
5 N stacks in an array n n https://www.codingninjas.com/studio/problems/n-stacks-in-an-array_1164271?leftPanelTabValue=PROBLEM
6 Online Stock Span (901) n n https://leetcode.com/problems/online-stock-span/description/
7 Simplify Path (71) n n https://leetcode.com/problems/simplify-path/
8 Check If Word Is Valid After Substitutions n n https://leetcode.com/problems/check-if-word-is-valid-after-substitutions/description/
9 Decode String (394) n+k n https://leetcode.com/problems/decode-string/
10 Maximal Rectangle (85) m*n m*n https://leetcode.com/problems/maximal-rectangle/
11 Car Fleet (853) nlogn n https://leetcode.com/problems/car-fleet/
12 Car Fleet II (1776) n n https://leetcode.com/problems/car-fleet-ii/

Releases

No releases published

Packages

No packages published

Languages