├── .vscode ├── c_cpp_properties.json └── settings.json ├── 01-introduction-to-c++ ├── README.md └── modules │ ├── 001-basics │ ├── README.md │ ├── assets │ │ ├── Basics-Variables-IO.pdf │ │ ├── Conditionals-Loops.pdf │ │ ├── FlowCharts.pdf │ │ └── Functions.pdf │ └── code │ │ ├── 001-C++-Intro.cpp │ │ ├── 002-Datatype.cpp │ │ ├── 003-IO.cpp │ │ ├── 004-Oper-Arithmatic-Relational-Logical.cpp │ │ ├── 005-Oper-Bitwise.cpp │ │ ├── 006-Conditions.cpp │ │ └── 007-Functions.cpp │ ├── 002-loops │ ├── README.md │ ├── assets │ │ ├── Conditionals-And-Loops.pdf │ │ ├── Operators-And-For-Loop.pdf │ │ └── Patterns.pdf │ ├── code-part-1 │ │ ├── 001-Check-Number-If-Prime.cpp │ │ ├── 002-Sum-Of-Even-Numbers-Till-N.cpp │ │ ├── 003-Farenheit-To-Celcius-Table.cpp │ │ ├── 004-Number-Pattern-1.cpp │ │ ├── 005-Number-Pattern-2.cpp │ │ ├── 006-Star-Pattern.cpp │ │ ├── 007-Total-Salary.cpp │ │ ├── 008-Sum-Of-Even-Odd.cpp │ │ └── 009-Find-Power-Of-Number.cpp │ ├── code-part-2 │ │ ├── 001-Square-Pattern.cpp │ │ ├── 002-Triangular-Star-Pattern.cpp │ │ ├── 003-Triangle-Number-Pattern.cpp │ │ ├── 004-Reverse-Number-Pattern.cpp │ │ ├── 005-Character-Pattern-Basic.cpp │ │ ├── 006-Alpha-Pattern.cpp │ │ ├── 007-Character-Pattern.cpp │ │ └── 008-Interesting-Pattern.cpp │ ├── code-part-3 │ │ ├── 001-Reverse-Triangle.cpp │ │ ├── 002-Mirror-Number-Pattern.cpp │ │ ├── 003-Inverted-Triangle.cpp │ │ ├── 004-Inverted-Number-Pattern.cpp │ │ ├── 005-Isoceles-Triangle.cpp │ │ ├── 006-Star-Pattern.cpp │ │ ├── 007-Triangle-Of-Numbers.cpp │ │ ├── 008-Diamond-Of-Stars.cpp │ │ ├── 009-Pattern-Medium-1.cpp │ │ ├── 010-Pattern-Medium-2.cpp │ │ └── 011-Pattern-Medium-3.cpp │ └── code-part-4 │ │ ├── 001-Nth-Fibonicci-Number.cpp │ │ ├── 002-All-Prime-Numers.cpp │ │ ├── 003-Count-Characters.cpp │ │ ├── 004-Sum-Or-Product.cpp │ │ ├── 005-Terms-Of-AP.cpp │ │ ├── 006-Reverse-Of-Number.cpp │ │ ├── 007-Binary-To-Decimal.cpp │ │ ├── 008-Decimal-To-Binary.cpp │ │ ├── 009-Square-Root-Integral.cpp │ │ └── 010-Check-Number-Sequence.cpp │ ├── 003-test-1 │ ├── README.md │ └── code │ │ ├── 001-Guess-Output.cpp │ │ ├── 002-Pyramid-Star-Pattern.cpp │ │ ├── 003-Number-Star-Pattern.cpp │ │ └── 004-Second-Largest.cpp │ ├── 004-arrays │ ├── README.md │ ├── assets │ │ ├── Arrays.pdf │ │ └── Character-And-2D-Arrays.pdf │ ├── code-part-1 │ │ ├── 001-Array-Sum.cpp │ │ ├── 002-Linear-Search.cpp │ │ ├── 003-Arrange-Numbers-In-Array.cpp │ │ ├── 004-Swap-Alternate.cpp │ │ ├── 005-Find-Unique.cpp │ │ ├── 006-Find-Duplicate.cpp │ │ ├── 007-Array-Intersection.cpp │ │ ├── 008-Pair-Sum.cpp │ │ ├── 009-Triplet-Sum.cpp │ │ └── 010-Sort-01.cpp │ ├── code-part-2 │ │ ├── 001-1D-Char-Array.cpp │ │ ├── 002-Check-Palindrome.cpp │ │ ├── 003-Replace-Character.cpp │ │ ├── 004-Trim-Spaces.cpp │ │ └── 005-Reverse-Word.cpp │ ├── code-part-3 │ │ ├── 001-Basic-2D-Arrays.cpp │ │ ├── 002-Column-Wise-Sum.cpp │ │ ├── 003-Largest-Row-Or-Column.cpp │ │ ├── 004-Wave-Print.cpp │ │ └── 005-Spiral-Print.cpp │ └── code-part-4 │ │ ├── 001-Check-Permutation.cpp │ │ ├── 002-Remove-Consecutive-Duplicates.cpp │ │ ├── 003-Reverse-Each-Word.cpp │ │ ├── 004-Remove-Character.cpp │ │ ├── 005-Highest-Occuring-Character.cpp │ │ └── 006-Compress-The-String.cpp │ ├── 005-searching-sorting │ ├── README.md │ ├── assets │ │ └── Searching-And-Sorting.pdf │ └── code │ │ ├── 001-Binary-Search.cpp │ │ ├── 002-Selection-Sort.cpp │ │ ├── 003-Bubble-Sort.cpp │ │ ├── 004-Insertion-Sort.cpp │ │ ├── 005-Merge-Two-Sorted-Arrays.cpp │ │ ├── 006-Push-Zeros-To-End.cpp │ │ ├── 007-Rotate-Array.cpp │ │ ├── 008-Second-Largest-Element.cpp │ │ ├── 009-Check-Array-Rotation.cpp │ │ ├── 010-Sort-012.cpp │ │ └── 011-Sum-Of-Two-Arrays.cpp │ ├── 006-string │ ├── README.md │ └── code │ │ ├── 001-Basics.cpp │ │ └── 002-Print-All-Substrings.cpp │ └── 007-test-2 │ ├── README.md │ └── code │ ├── 001-Print-2D-Array.cpp │ ├── 002-Minimum-Length-Word.cpp │ └── 003-Leaders-In-Array.cpp ├── 02-data-structure-algorithms ├── README.md └── modules │ ├── 001-basics │ ├── README.md │ ├── assets │ │ └── pointers.pdf │ └── code │ │ ├── 001-Basics-Pointers.cpp │ │ ├── 002-Assignments-Pointers.cpp │ │ ├── 003-Type-Casting.cpp │ │ ├── 004-Dynamic-Memory.cpp │ │ ├── 005-Pass-By-Reference.cpp │ │ ├── 006-GlobalVariables-Constant.cpp │ │ └── 007-Vector-Usage.cpp │ ├── 002-recursion │ ├── README.md │ ├── assets │ │ └── Recursion.pdf │ ├── code-part-1 │ │ ├── 001-Factorial.cpp │ │ ├── 002-Power.cpp │ │ ├── 003-Print-Numbers.cpp │ │ ├── 004-Number-Of-Digits.cpp │ │ ├── 005-Nth-Number.cpp │ │ ├── 006-Check-If-Array-Is-Sorted.cpp │ │ ├── 007-Sum-Of-Array.cpp │ │ ├── 008-Check-Number.cpp │ │ ├── 009-First-Index-Of-Number.cpp │ │ ├── 010-Last-Index-Of-Number.cpp │ │ ├── 011-All-Indices-Of-Number.cpp │ │ ├── 012-Multiplication-Recursive.cpp │ │ ├── 013-Count-Zeros.cpp │ │ ├── 014-Geometric-Sum.cpp │ │ ├── 015-Check-Palindrome.cpp │ │ └── 016-Sum-Of-Digits.cpp │ ├── code-part-2 │ │ ├── 001-Replace-Pi.cpp │ │ ├── 002-Remove-X.cpp │ │ ├── 003-String-To-Integer.cpp │ │ ├── 004-Pair-Star.cpp │ │ ├── 005-Tower-Of-Hanoi.cpp │ │ ├── 006-Replace-Character-recursive.cpp │ │ ├── 007-Remove-Duplicates-Recursive.cpp │ │ ├── 008-Merge-Sort.cpp │ │ └── 009-Quick-Sort.cpp │ └── code-part-3 │ │ ├── 001-Strings.cpp │ │ ├── 002-All-SubSequences.cpp │ │ ├── 003-Return-Keypad-Codes.cpp │ │ ├── 004-Print-Keypad-Code.cpp │ │ ├── 005-Check-AB.cpp │ │ ├── 006-StairCase.cpp │ │ ├── 007-Binary-Search-Recursive.cpp │ │ ├── 008-Return-Subsets-Of-Array.cpp │ │ ├── 009-Print-Subsets-Of-Array.cpp │ │ ├── 010-Return-Subsets-Sum-To-K.cpp │ │ ├── 011-Print-Subsets-Sum-To-K.cpp │ │ ├── 012-Return-All-Codes.cpp │ │ ├── 013-Print-All-Codes.cpp │ │ ├── 014-Return-Permutations.cpp │ │ └── 015-Print-Permutations.cpp │ ├── 003-complexity │ ├── README.md │ ├── assets │ │ └── Time-Complexity.pdf │ └── code │ │ ├── 001-Basic-Guess-Output.cpp │ │ ├── 002-Find-Unique-Element.cpp │ │ ├── 003-Duplicate-In-An-Array.cpp │ │ ├── 004-Array-Intersection.cpp │ │ ├── 005-Pair-Sum-In-Array.cpp │ │ ├── 006-Triplet-Sum.cpp │ │ ├── 007-Rotate-Array.cpp │ │ └── 008-Check-Array-Rotation.cpp │ ├── 004-test-1 │ ├── README.md │ └── code │ │ ├── 001-MCQ.cpp │ │ ├── 002-Does-S-Contains-T.cpp │ │ ├── 003-Maximum-Profit-App.cpp │ │ └── 004-Split-Array.cpp │ ├── 005-oops │ ├── README.md │ ├── assets │ │ ├── OOPS-1-Classes-Members-Constructor-this.pdf │ │ ├── OOPS-3-Exception-Handling.pdf │ │ └── inheritance-1.png │ ├── code-part-1 │ │ ├── 001-Play-With-Classes-Assignments.cpp │ │ ├── 002-Fraction-Class.cpp │ │ └── 003-Complex-Number.cpp │ ├── code-part-2 │ │ ├── 001-Play-With-Constructors.cpp │ │ ├── 002-Deep-Shallow-Copy.cpp │ │ ├── 003-Const-Static-Members.cpp │ │ ├── 004-Assignments-Constructor-Static-Const.cpp │ │ ├── 005-Operator-Overloading-Fraction-Class.cpp │ │ └── 006-Polynomial-Class.cpp │ └── code-part-3 │ │ ├── 001-Inheritance.cpp │ │ ├── 002-Polymorphism.cpp │ │ └── 003-Virtual-Abstract-Friend.cpp │ ├── 006-linkedlist │ ├── README.md │ ├── code-part-1 │ │ ├── 001-SinglyLinkedList-Impl.cpp │ │ ├── 002-Guess-Output.cpp │ │ ├── 003-Print-ith-Node.cpp │ │ ├── 004-Delete-Node.cpp │ │ ├── 005-Length-LinkedList-Recursive.cpp │ │ ├── 006-Insert-Node-Recursive.cpp │ │ ├── 007-Delete-Node-Recursive.cpp │ │ ├── 008-Find-Node.cpp │ │ ├── 009-Append-Last-N-To-First.cpp │ │ ├── 010-Eliminate-Duplicates-From-LL.cpp │ │ ├── 011-Print-Reverse-LinkedList.cpp │ │ └── 012-Palindrome-LinkedList.cpp │ └── code-part-2 │ │ ├── 001-Mid-Point-LinkedList.cpp │ │ ├── 002-Merge-Two-Sorted-LinkedList.cpp │ │ ├── 003-Merge-Sort.cpp │ │ ├── 004-Reverse-LinkedList-Recursive.cpp │ │ ├── 005-Find-Node-In-LinkedList-Recursive.cpp │ │ ├── 006-Even-After-Odd-LinkedList.cpp │ │ ├── 007-Delete-Every-N-Nodes.cpp │ │ ├── 008-Swap-Two-Nodes-LinkedList.cpp │ │ ├── 009-kReverse.cpp │ │ └── 010-Bubble-Sort-Iterative.cpp │ ├── 007-stack │ ├── README.md │ └── code │ │ ├── 001-Stack-Impl-Arrays.cpp │ │ ├── 002-Stack-Impl-LinkedList.cpp │ │ ├── 003-Balanced-Parenthesis.cpp │ │ ├── 004-Reverse-Stack.cpp │ │ ├── 005-Check-Redundant-Brackets.cpp │ │ ├── 006-Stock-Span.cpp │ │ └── 007-Minimum-Brackets-Reversal.cpp │ ├── 008-queue │ ├── README.md │ └── code │ │ ├── 001-Queue-Impl-Array.cpp │ │ ├── 002-Queue-Impl-LinkedList.cpp │ │ └── 003-Reverse-Queue.cpp │ ├── 009-test-2 │ ├── README.md │ └── code │ │ ├── 001-Next-Number.cpp │ │ ├── 002-Deque.cpp │ │ └── 003-Delete-Alternate-Nodes.cpp │ ├── 010-trees │ ├── README.md │ └── code │ │ ├── 001-Print-Tree-Recursive.cpp │ │ ├── 002-Print-Tree-Level-Order-Traversal.cpp │ │ ├── 003-Count-Number-Of-Nodes.cpp │ │ ├── 004-Find-Sum-Of-Nodes.cpp │ │ ├── 005-Max-Data-Node.cpp │ │ ├── 006-Find-Height.cpp │ │ ├── 007-Count-Leaf-Nodes.cpp │ │ ├── 008-Print-Pre-Post-Traversal.cpp │ │ ├── 009-Contains-X.cpp │ │ ├── 010-Count-Nodes.cpp │ │ ├── 011-Node-With-Max-Child-Sum.cpp │ │ ├── 012-Structurally-Identical.cpp │ │ ├── 013-Next-Larger.cpp │ │ ├── 014-SecondLargest-Element.cpp │ │ └── 015-Replace-With-Depth.cpp │ ├── 011-binary-trees │ ├── README.md │ └── code │ │ ├── 001-Print-BinaryTree-Recursive.cpp │ │ ├── 002-Print-Level-Order-Traversal.cpp │ │ ├── 003-Count-Nodes.cpp │ │ ├── 004-Find-Node.cpp │ │ ├── 005-Height-Of-Binary-Tree.cpp │ │ ├── 006-Mirror.cpp │ │ ├── 007-Pre-Post-In-Order-Traversal.cpp │ │ ├── 008-Construct-Tree-From-PreOrder-InOrder.cpp │ │ ├── 009-Construct-Tree-From-PostOrder-InOrder.cpp │ │ ├── 010-Diameter-Of-Binary-Tree.cpp │ │ ├── 011-Min-Max-In-Binary-Tree.cpp │ │ ├── 012-Sum-Of-Nodes.cpp │ │ ├── 013-Check-Balanced.cpp │ │ ├── 014-Level-Order-Traversal.cpp │ │ ├── 015-Remove-Leaf-Nodes.cpp │ │ ├── 016-Level-Wise-LinkedList.cpp │ │ ├── 017-ZigZag-Tree.cpp │ │ └── 018-Nodes-Without-Siblings.cpp │ ├── 012-binary-search-trees │ ├── README.md │ └── code │ │ ├── 001-BST-Impl.cpp │ │ ├── 002-Search-Node-BST.cpp │ │ ├── 003-Print-Elements-In-Range.cpp │ │ ├── 004-Check-BST.cpp │ │ ├── 005-Construct-BST-From-Sorted-Array.cpp │ │ ├── 006-BST-To-Sorted-Linked-List.cpp │ │ ├── 007-Root-To-Node-Path.cpp │ │ ├── 008-Find-Path-In-BST.cpp │ │ ├── 009-Create-And-Insert-Duplicate-Node.cpp │ │ ├── 010-Pair-Sum-Binary-Tree.cpp │ │ ├── 011-LCA-Of-Binary-Tree.cpp │ │ ├── 012-LCA-Of-BST.cpp │ │ ├── 013-Largest-BST.cpp │ │ ├── 014-Replace-With-Sum-Of-Greater-Nodes.cpp │ │ ├── 015-Path-Sum-To-Root.cpp │ │ ├── 016-Print-Nodes-At-Distance-K.cpp │ │ └── 017-Pair-Sum-In-BST.cpp │ ├── 013-test-3 │ ├── README.md │ └── code │ │ ├── 001-Check-Cousin.cpp │ │ ├── 002-Longest-Leaf-To-Root-Path.cpp │ │ ├── 003-Remove-Leaf-Node.cpp │ │ └── BinaryTreeNode.h │ ├── 014-priority-queue │ ├── README.md │ └── code │ │ ├── 001-Min-Priority-Queue-Impl.cpp │ │ ├── 002-Max-Priority-Queue-Impl.cpp │ │ ├── 003-Heap-Sort.cpp │ │ ├── 004-InBuilt-PQ-Usage.cpp │ │ ├── 005-K-Sorted-Array.cpp │ │ ├── 006-K-Smallest-Elements.cpp │ │ ├── 007-K-Largest-Elements.cpp │ │ ├── 008-Check-Max-Heap.cpp │ │ ├── 009-Kth-Largest-Element.cpp │ │ ├── 010-Merge-K-Sorted-Arrays.cpp │ │ ├── 011-Running-Median.cpp │ │ └── 012-Buy-The-Ticket.cpp │ ├── 015-hashmap │ ├── README.md │ └── code │ │ ├── 001-HashMap-Impl.cpp │ │ ├── 002-Basic-Usage.cpp │ │ ├── 003-Remove-Duplicates.cpp │ │ ├── 004-Maximum-Frequency-Number.cpp │ │ ├── 005-Print-Intersection.cpp │ │ ├── 006-Pair-Sum.cpp │ │ ├── 007-Extract-Unique-Characters.cpp │ │ ├── 008-Longest-Consecutive-Sequence.cpp │ │ ├── 009-Pairs-With-Diff-K.cpp │ │ └── 010-Largest-Subset-Zero-Sum.cpp │ ├── 016-tries │ ├── README.md │ ├── code │ │ ├── 001-Trie-Implementation.cpp │ │ ├── 002-Pattern-Matching.cpp │ │ ├── 003-Palindrome-Pair.cpp │ │ └── 004-Auto-Complete.cpp │ └── images │ │ └── trie-1.png │ ├── 017-dynamic-programming │ ├── README.md │ ├── code-part-1 │ │ ├── 001-Fibonicci.cpp │ │ ├── 002-Count-Setps-To-One.cpp │ │ ├── 003-StairCase.cpp │ │ ├── 004-Minimum-Count.cpp │ │ └── 005-Num-Balanced-BTs.cpp │ └── code-part-2 │ │ ├── 001-Min-Cost-Path.cpp │ │ ├── 002-lcs.cpp │ │ ├── 003-Edit-Distance.cpp │ │ ├── 004-knapsack.cpp │ │ ├── 005-Loot-Houses.cpp │ │ ├── 006-longest-incresing-subsequence.cpp │ │ ├── 007-All-Possible-Ways.cpp │ │ ├── 008-Ways-To-Make-Coin-Change.cpp │ │ ├── 009-Matrix-Chain-Multiplication.cpp │ │ ├── 010-Coin-Tower.cpp │ │ ├── 011-Max-Square-Matrix-With-Zeros.cpp │ │ └── 012-Shortest-Subsequence.cpp │ ├── 018-graphs │ ├── README.md │ ├── code-part-1 │ │ ├── 001-Print-Nodes-DFS.cpp │ │ ├── 002-Print-Nodes-BFS.cpp │ │ ├── 003-Has-Path.cpp │ │ ├── 004-Get-Path-DFS.cpp │ │ ├── 005-Get-Path-BFS.cpp │ │ ├── 006-Is-Connected.cpp │ │ ├── 007-All-Connected-Components.cpp │ │ ├── 008-Islands.cpp │ │ ├── 009-CodingNinjas.cpp │ │ ├── 010-Connecting-Dots.cpp │ │ ├── 011-Largest-Piece.cpp │ │ └── 012-3-Cycle.cpp │ └── code-part-2 │ │ ├── 001-Kruskals-Algo.cpp │ │ ├── 002-Prims-Algo.cpp │ │ └── 003-Dijkstra-Algo.cpp │ ├── 019-backtracking │ ├── README.md │ └── code │ │ ├── 001-N-Queen.cpp │ │ ├── 002-Rat-In-A-Maze.cpp │ │ ├── 003-Crossword.cpp │ │ ├── 004-Sudoku.cpp │ │ └── 005-Subsets-Sum.cpp │ └── 020-misc-skill-tests │ ├── README.md │ ├── code-skill-test-1 │ ├── 001-Number-Star-Patter.cpp │ ├── 002-Donuts.cpp │ ├── 003-Maximum-Subarray-Sum.cpp │ └── 004-One-Strings.cpp │ ├── code-skill-test-2 │ ├── 001-Power.cpp │ ├── 002-All-Possible-Ways.cpp │ ├── 003-Binary-Play.cpp │ └── 004-Quadruplet-Sum.cpp │ ├── code-skill-test-3 │ ├── 002-Symmetric-Binary-Tree.cpp │ ├── 003-War-On-NinjaLand.cpp │ ├── 004-Find-The-Celebrity.cpp │ └── InBetweenLinkedList_1.java │ └── code-skill-test-4 │ ├── 002-White-SubTree.cpp │ ├── 003-Jumping-Ninja.cpp │ ├── 004-Help-Pradyumana.cpp │ └── SpyAmongUs.java ├── 03-competitive-programming ├── README.md └── modules │ ├── 001-prerequisite │ ├── README.md │ ├── code │ │ ├── 001-Add-Numbers-Out-In-File.cpp │ │ ├── 002-Calculate-Area-Of-Intersection.cpp │ │ ├── 003-Print-Zig-Zag-Array.cpp │ │ ├── 004-Even-And-Odd-Indexes.cpp │ │ ├── 005-Total-Sum-Boundaries-Diagonals.cpp │ │ ├── 006-PRE4.cpp │ │ ├── 007-Target-Marbles.cpp │ │ └── 008-Oscillating-Prices-Of-Chakri.cpp │ └── io │ │ ├── addin.txt │ │ ├── addout.txt │ │ ├── areain.txt │ │ ├── areaout.txt │ │ ├── zigzag_array_in.txt │ │ └── zigzag_array_out.txt │ ├── 002-pointers │ ├── README.md │ ├── assets │ │ └── pointers.pdf │ └── code │ │ ├── 001-Pointers.cpp │ │ ├── 002-Pointer-Arithmetic.cpp │ │ ├── 003-Arrays-And-Pointers.cpp │ │ ├── 004-Character-Pointers.cpp │ │ ├── 005-Pointers-And-Functions.cpp │ │ └── 006-Double-Pointers.cpp │ ├── 003-dynamic-allocation │ ├── README.md │ └── code │ │ ├── 001-Address-Typecasting.cpp │ │ ├── 002-Pass-By-Reference.cpp │ │ ├── 003-Dynamic-Memory-Allocation.cpp │ │ ├── 004-Macros-Global-Vars.cpp │ │ ├── 005-Inline-Default-Arguments.cpp │ │ └── 006-Constant-Vars.cpp │ ├── 004-recursion │ ├── README.md │ ├── assets │ │ └── recursion.pdf │ └── code │ │ ├── 001-Factorial.cpp │ │ ├── 002-Power.cpp │ │ ├── 003-Print-Numbers.cpp │ │ ├── 004-Number-Of-Digits.cpp │ │ ├── 005-Fibonicci.cpp │ │ ├── 006-Guess-Output.cpp │ │ ├── 007-Check-If-Array-Sorted.cpp │ │ ├── 008-Sum-Of-Array.cpp │ │ ├── 009-Check-Number.cpp │ │ ├── 010-First-Index-Of-Number.cpp │ │ ├── 011-Last-Index-Of-Number.cpp │ │ └── 012-All-indices-Of-Number.cpp │ ├── 005-Complexity-And-Language-Tools │ ├── README.md │ ├── assets │ │ ├── CP-Notes-Language-Tools.pdf │ │ ├── Language-Tools-C++.pdf │ │ ├── Language-Tools-Java.pdf │ │ ├── Language-Tools-Python.pdf │ │ └── Time-Space-Complexity.pdf │ ├── code-part-1 │ │ ├── 001-Guess-Output.cpp │ │ ├── 002-Kadane-Algorithm.cpp │ │ ├── 003-K-Concatenation.cpp │ │ ├── 004-Maximum-Product-Subarray.cpp │ │ └── 005-Mindbending-Product.cpp │ ├── code-part-2 │ │ ├── 001-Hussain-Set.cpp │ │ ├── 002-Voters-List.cpp │ │ ├── 003-Permutation-And-Palindrome.cpp │ │ ├── 004-Love-For-Characters.cpp │ │ ├── 005-Different-Names.cpp │ │ ├── 006-Extract-Unique-Characters.cpp │ │ ├── 007-Warm-Reception.cpp │ │ └── 008-Tell-The-Positions.cpp │ └── code-part-3 │ │ ├── 001-Duplicate-In-Array.cpp │ │ ├── 002-Triplet-Sum.cpp │ │ ├── 003-Rotate-Array.cpp │ │ ├── 004-Find-Unique-Element.cpp │ │ ├── 005-Sum-Me-Up.cpp │ │ ├── 006-Pair-Sum-To-Zero.cpp │ │ └── 007-Longest-Consecutive-Sequence.cpp │ ├── 006-searching-sorting │ ├── README.md │ ├── assets │ │ └── Searching-And-Sorting-Applications.pdf │ └── code │ │ ├── 001-Aggressive-Cows.cpp │ │ ├── 002-Inversion-Count.cpp │ │ ├── 003-Chef-Restaurant.cpp │ │ ├── 004-Variation-Pairs.cpp │ │ ├── 005-Murder.cpp │ │ ├── 006-Distribute-Candies.cpp │ │ ├── 007-Momos-Market.cpp │ │ └── 008-Taj-Mahal-Entry.cpp │ ├── 007-Advance-Recursion │ ├── README.md │ ├── assets │ │ └── Advanced-Recursion.pdf │ └── code │ │ ├── 001-Length.cpp │ │ ├── 002-Replace-Character-Recursive.cpp │ │ ├── 003-Remove-Duplicates-Recursive.cpp │ │ ├── 004-Merge-Sort.cpp │ │ ├── 005-Quick-Sort.cpp │ │ ├── 006-Return-Subsequences.cpp │ │ ├── 007-Return-Keypad-Code.cpp │ │ ├── 008-Print-SubSequences.cpp │ │ └── 009-Print-Keypad-Combination.cpp │ ├── 008-Backtracking │ ├── README.md │ ├── assets │ │ └── Backtracking.pdf │ ├── code-part-1 │ │ ├── 001-nQueens.cpp │ │ ├── 002-RatInAMaze.cpp │ │ └── 003-Crossword.cpp │ └── code-part-2 │ │ ├── 001-Find-Power.cpp │ │ ├── 002-Sorting-Skills.cpp │ │ ├── 003-Collecting-Balls.cpp │ │ └── 004-Sudoku-Solver.cpp │ ├── 009-Bit-Manipulation │ ├── README.md │ ├── assets │ │ └── Bit-Manipulation.pdf │ └── code │ │ ├── 001-Bitwise-Operators.cpp │ │ ├── 002-Set-ith-Bit.cpp │ │ ├── 003-Unset-ith-Bit.cpp │ │ ├── 004-Flip-the-ith-Bit.cpp │ │ ├── 005-Check-If-Number-Even-Odd.cpp │ │ ├── 006-Check-Power-Of-Two.cpp │ │ ├── 007-Find-First-Set-Bit.cpp │ │ ├── 008-Turn-Off-The-First-Bit.cpp │ │ ├── 009-Clear-All-Bit-From-LSB.cpp │ │ └── 010-Clear-All-Bits-From-MSB.cpp │ ├── 010-Adhoc-Problems │ ├── README.md │ ├── assets │ │ └── Adhoc-Problems.pdf │ └── code │ │ ├── 001-Equalize.cpp │ │ ├── 002-Rectangular-Area.cpp │ │ ├── 003-Light-Up-The-Bulb.cpp │ │ ├── 004-Circular-List-Of-Students.cpp │ │ ├── 005-Interesting-Sequence.cpp │ │ └── 006-Winning-Strategy.cpp │ ├── 011-Modulo-Arithmetic │ ├── README.md │ ├── assets │ │ └── Modulo-Arithmetic.pdf │ └── code │ │ └── 001-Number-Of-Balanced-Trees.cpp │ ├── 012-Dynamic-Programming │ ├── README.md │ ├── assets │ │ ├── Dynamic-Programming-1.pdf │ │ └── Dynamic-Programming-2.pdf │ ├── code-part-1 │ │ ├── 001-Fibonicci.cpp │ │ ├── 002-AlphaCode.cpp │ │ ├── 003-longest-incresing-subsequence.cpp │ │ ├── 004-Longest-Bitionic-Subarray.cpp │ │ ├── 005-StairCase.cpp │ │ ├── 006-Coin-Change-Problem.cpp │ │ ├── 007-Min-Cost-Dp.cpp │ │ ├── 008-Get-Minimum-Strength.cpp │ │ ├── 009-Max-Sum-Rectangle.cpp │ │ ├── 010-Construct-Array.cpp │ │ └── 011-Sam-And-Substring.cpp │ ├── code-part-2 │ │ ├── 001-Loot-Houses.cpp │ │ ├── 002-Max-squares-with-all-zeros.cpp │ │ ├── 003-Cont-BSTs.cpp │ │ ├── 004-Boredom.cpp │ │ ├── 005-Min-Number-Of-Choclates.cpp │ │ ├── 006-Minimum-Count.cpp │ │ ├── 007-Hasan-And-Trip.cpp │ │ ├── 008-Vanya-And-GCD.cpp │ │ ├── 009-Adjacent-Bit-Counts.cpp │ │ ├── 010-Roy-And-Coin-Boxes.cpp │ │ ├── 011-Jon-Snow-And-Fav-Number.cpp │ │ ├── 012-Alyona-And-Spreadsheet.cpp │ │ └── 013-Angry-Children.cpp │ └── code-part-3 │ │ ├── 001-LCS.cpp │ │ ├── 002-Edit-Distance.cpp │ │ ├── 003-Balika-Vadhu.cpp │ │ ├── 004-knapsack.cpp │ │ ├── 005-Party.cpp │ │ ├── 006-Subset-Sum.cpp │ │ ├── 007-Miser-Man.cpp │ │ ├── 008-Trader-Profit.cpp │ │ ├── 009-Charlie-And-Pilots.cpp │ │ ├── 010-Square-Brackets.cpp │ │ ├── 011-Distinct-Subsequence.cpp │ │ ├── 012-Smallest-Super-Sequence.cpp │ │ └── 013-Shortest-Subsequence.cpp │ ├── 013-Greedy-Problems │ ├── README.md │ ├── assets │ │ └── Greedy-Problems.pdf │ └── code │ │ ├── 001-Min-Absolute-Diff-In-An-Array.cpp │ │ ├── 002-Nikunj-And-Donuts.cpp │ │ ├── 003-Activity-Selection.cpp │ │ ├── 004-Fractional-Knapsack.cpp │ │ ├── 005-Weighted-Job-Scheduling.cpp │ │ ├── 006-Perimeter-With-Conditions.cpp │ │ ├── 007-Problem-Discussion.cpp │ │ └── 008-Winning-Lottery.cpp │ ├── 014-Segment-Trees │ ├── README.md │ ├── assets │ │ └── Segment-Trees.pdf │ └── code │ │ ├── 001-Segment-Tree-Operations.cpp │ │ ├── 002-Minimum-In-Subarray.cpp │ │ ├── 003-Maximum-Pair-Sum.cpp │ │ ├── 004-Maximum-Sum-In-Subarray.cpp │ │ ├── 005-Lazy-Propagation.cpp │ │ ├── 006-Sum-Of-Squares.cpp │ │ ├── 007-Counting-Even-Odd.cpp │ │ ├── 008-Vasya-vs-Rhezo.cpp │ │ ├── 009-2-vs-3.cpp │ │ └── 010-Horrible-Queries.cpp │ ├── 015-Graphs │ ├── README.md │ ├── assets │ │ ├── Advance-Graphs.pdf │ │ ├── Graphs-1.pdf │ │ └── Graphs-2.pdf │ ├── code-part-1 │ │ ├── 001-Print-Nodes-DFS.cpp │ │ ├── 002-Print-Nodes-BFS.cpp │ │ ├── 003-Has-Path.cpp │ │ ├── 004-Get-Path-DFS.cpp │ │ ├── 005-Get-Path-BFS.cpp │ │ ├── 006-Is-Connected.cpp │ │ ├── 007-All-Connected-Components.cpp │ │ ├── 008-Islands.cpp │ │ ├── 009-CodingNinjas.cpp │ │ ├── 010-Connecting-Dots.cpp │ │ ├── 011-Largest-Piece.cpp │ │ └── 012-3-Cycle.cpp │ ├── code-part-2 │ │ ├── 001-Kruskals-Algo.cpp │ │ ├── 002-Prims-Algo.cpp │ │ └── 003-Dijkstra-Algo.cpp │ └── code-part-3 │ │ ├── 001-Connected-Components.cpp │ │ ├── 002-Permutation-Swaps.cpp │ │ ├── 003-Connected-Horses.cpp │ │ ├── 004-Strongly-Connected-Components.cpp │ │ ├── 005-Dominos.cpp │ │ ├── 006-BOTTOM.cpp │ │ ├── 007-Bipartite-Graph.cpp │ │ ├── 008-FILLMTR-Fill-Matrix.cpp │ │ ├── 009-Monk-and-the-Islands.cpp │ │ ├── 010-Kingdom-Of-Monkeys.cpp │ │ ├── 011-New-Year-Transportation.cpp │ │ ├── 012-AIRPORTS.cpp │ │ └── 013-Edges-In-MST.cpp │ ├── 016-String-Algorithms │ ├── README.md │ ├── assets │ │ └── String-Algorithms.pdf │ └── code │ │ ├── 001-Pattern-Matching-Naive.cpp │ │ ├── 002-Longest-Prefix-Suffix.cpp │ │ ├── 003-KMP-Algorithm.cpp │ │ ├── 004-String-Search.cpp │ │ ├── 005-Z-Algorithm.cpp │ │ ├── 006-Longest-Palindromic-Substring.cpp │ │ └── 007-Palindromic-Substrings.cpp │ ├── 017-Tries │ ├── README.md │ ├── assets │ │ └── Tries.pdf │ └── code │ │ ├── 001-XOR-Maximum-Pair.cpp │ │ ├── 002-Maximum-XOR-subarray.cpp │ │ ├── 003-SUBXOR.cpp │ │ ├── 004-Search-Engine.cpp │ │ └── 005-Help-Me-Pradyumana.cpp │ ├── 018-Fenwick-Tree │ ├── README.md │ ├── assets │ │ └── Fenwick-Tree.pdf │ └── code │ │ ├── 001-Fenwick-Tree-Oper.cpp │ │ ├── 002-Coders-Rating.cpp │ │ ├── 003-Distinct-Elements.cpp │ │ ├── 004-Order-Set.cpp │ │ ├── 005-KQUERY.cpp │ │ ├── 006-Shil-And-Wave-Sequence.cpp │ │ └── 007-INCSEQ.cpp │ ├── 019-DP-And-Bitmasking │ ├── README.md │ ├── assets │ │ └── DP-And-Bitmasking.pdf │ └── code │ │ ├── 001-Minimum-Job-Cost.cpp │ │ ├── 002-Candy.cpp │ │ ├── 003-Ghost-Type.cpp │ │ ├── 004-Dilemma.cpp │ │ ├── 005-Mehta-And-Bank-Robbery.cpp │ │ ├── 006-String-Maker.cpp │ │ ├── 007-Counting-Strings.cpp │ │ └── 008-Number-Of-APs.cpp │ ├── 020-Number-Theory-1 │ ├── README.md │ ├── assets │ │ ├── Number-Theory-1.pdf │ │ └── Number-Theory-2.pdf │ ├── code-part-1 │ │ ├── 001-Find-Prime-Numbers-1-to-N.cpp │ │ ├── 002-Sieve-Of-Eratosthenes.cpp │ │ ├── 003-GCD-Euclid-Algorithm.cpp │ │ ├── 004-Extended-Euclid-Algorithm.cpp │ │ └── 005-Multiplicative-Modulo-Inverse.cpp │ └── code-part-2 │ │ ├── 001-Sachin-And-Varun-Problem.cpp │ │ ├── 002-Advanced-GCD.cpp │ │ ├── 003-Divisors-Of-Factorial.cpp │ │ ├── 004-Find-The-Cube-Free-Number.cpp │ │ ├── 005-Number-Of-Factors.cpp │ │ ├── 006-Find-the-good-sets.cpp │ │ ├── 007-Card-Game.cpp │ │ └── 008-Strange-Order.cpp │ ├── 021-Number-Theory-2 │ ├── README.md │ ├── assets │ │ └── Number-Theory-3.pdf │ └── code │ │ ├── 001-Euler-Totient-Function.cpp │ │ ├── 002-LCM-SUM.cpp │ │ └── 003-Segment-Sieve.cpp │ ├── 022-Number-Theory-3 │ ├── README.md │ ├── assets │ │ └── Number-Theory-4.pdf │ └── code │ │ ├── 001-Modular-Exponentiation.cpp │ │ ├── 002-Nth-Fibonaaci-Number.cpp │ │ ├── 003-Fibonacci-Sum.cpp │ │ ├── 004-Fermats-Little-Theorem.cpp │ │ ├── 005-Wilson-Theorem.cpp │ │ ├── 006-Boring-Factorials.cpp │ │ ├── 007-Income-On-Nth-Day.cpp │ │ ├── 008-Cubic-Square.cpp │ │ ├── 009-GCD-Extreme.cpp │ │ ├── 010-Sanchit-And-Nuclear-Reactor.cpp │ │ ├── 011-Innocent-Swaps-and-His-Emotions.cpp │ │ └── 012-Sehwag-And-ETF.cpp │ ├── 023-Game-Theory │ ├── README.md │ ├── assets │ │ └── Game-Theory.pdf │ └── code │ │ ├── 001-Calculate-Grundy-Number.cpp │ │ ├── 002-Othello.cpp │ │ └── 003-Optimal-Move-In-Tic-Tac-Toe.cpp │ ├── 024-Computational-Geometry │ ├── README.md │ ├── assets │ │ └── Computational-Geometry.pdf │ └── code │ │ ├── 001-Area-Of-A-Polygon.cpp │ │ ├── 002-Area-Of-Convex-Polygon.cpp │ │ ├── 003-Surveyor.cpp │ │ ├── 004-Warehouse.cpp │ │ └── 005-Convex-Hull.cpp │ └── 025-FFT │ ├── README.md │ └── code │ └── 001-FFT.cpp ├── 04-aptitude ├── README.md └── modules │ ├── 001-HCF-and-LCM.cpp │ ├── 002-Averages.cpp │ ├── 003-Alligations.cpp │ ├── 004-Percentages.cpp │ ├── 005-Ratio-Proportaion-Variation-1.cpp │ ├── 006-Profit-And-Loss.cpp │ ├── 007-Ratio-Proportaion-Variation-2.cpp │ ├── 008-Time-Ans-Work.cpp │ ├── 009-Reasoning-1.cpp │ ├── 010-Permutation-Combination.cpp │ ├── 011-Probability.cpp │ ├── 012-Time-Speed-Distance.cpp │ ├── 013-Blood-Relation-Calenders.cpp │ ├── 014-Applications-Of-Time-Speed-Distance.cpp │ ├── 015-Set-Theory-Mensuration-Log.cpp │ └── 016-Important-Topics.cpp ├── 05-introduction-to-os ├── README.md └── assets │ ├── 01-Introduction-of-OS.pdf │ ├── 02-Installation-Of-Ubuntu-In-Virtual-Machine.pdf │ ├── 03-Introduction-to-Linux-Terminal.pdf │ ├── 04-Summary-Document-Introduction-of-OS.pdf │ ├── 05-Introduction-to-Process.pdf │ ├── 06-Process-Scheduling-Algorithms-1.pdf │ ├── 07-Preemptive-SJF-And-RR-Scheduling-Algorithms.pdf │ ├── 08-Process-Scheduling-Algorithms-2.pdf │ ├── 09-Memory-Management-1.pdf │ ├── 10-Functions-in-C-for-Memory-Management.pdf │ ├── 11-Memory-Management-2.pdf │ ├── 12-Non-Contiguous-Memory-Allocation-and-Virtual-Memory.pdf │ ├── 13-Concurrency-Introduction.pdf │ ├── 14-Concurrency-Key-Notes.pdf │ ├── 15-Failed-Attempt-To-Solve-Race-Condition.pdf │ ├── 16-Petersons-Solution.pdf │ ├── 17-Hardware-And-OS-Support.pdf │ ├── 18-Producer-And-Consumer-Problem.pdf │ ├── 19-Mutexes-Vs-Semaphores.pdf │ ├── 20-Summary-Concurrency.pdf │ ├── 21-Introduction-to-Storage-Management.pdf │ ├── 22-Introduction-to-Files-and-Directories.pdf │ ├── 23-Introduction-to-Disk-Space-Allocation-Methods.pdf │ └── 24-Summary-Storage-Management.pdf ├── 06-system-design ├── README.md ├── assets │ ├── 001-Introduction-to-system-design.pdf │ ├── 002-HLD-And-LLD.pdf │ ├── 003-Monolithic-Architecture.pdf │ ├── 004-Distributed-System.pdf │ ├── 005-Latency.pdf │ ├── 006-Throughput.pdf │ ├── 007-Availability.pdf │ ├── 008-Consistency.pdf │ ├── 009-CAP-Theorem.pdf │ ├── 010-Time.pdf │ ├── 011-Redundancy-And-Replication.pdf │ ├── 012-Load-Balancers.pdf │ ├── 013-Load-Balancing-Algorithms.pdf │ ├── 014-Caching.pdf │ ├── 015-Caching-Strategies.pdf │ ├── 016-Databases.pdf │ ├── 017-Indexing.pdf │ ├── 018-Partitioning.pdf │ ├── 019-Synchronous-Communication.pdf │ ├── 020-Asynchronous-Communication.pdf │ ├── 021-Message-Based-Communication.pdf │ ├── 022-Web-Application.pdf │ ├── 023-REST-API.pdf │ ├── 024-Service-Oriented-Architecture.pdf │ ├── 025-Microservice-Architecture.pdf │ ├── 026-Tier-Architecture.pdf │ ├── 027-Web-Servers.pdf │ ├── 028-Communication-Protocols.pdf │ ├── 029-Proxies.pdf │ └── 030-Application-Security.pdf └── code │ ├── 001-Introduction.cpp │ ├── 002-Architecture-Patterns.cpp │ ├── 003-Application-Characteristics-1.cpp │ ├── 004-Application-Characteristics-2.cpp │ ├── 005-Scaling-Techniques.cpp │ ├── 006-Databases.cpp │ ├── 007-Database-Optimization.cpp │ ├── 008-Communication.cpp │ ├── 009-Web-Applications.cpp │ ├── 010-Servers-And-Security.cpp │ ├── 011-Additional-Practice-Questions-I.cpp │ └── 012-Additional-Practice-Questions-II.cpp ├── 07-Introduction-to-DBMS ├── README.md ├── assets │ ├── 001-Introduction-to-DBMS.pdf │ ├── 002-Need-for-DBMS.pdf │ ├── 003-Data-Models.pdf │ ├── 004-Schemas.pdf │ ├── 005-Schema-Architecture.pdf │ ├── 006-Advanced-Concepts.pdf │ ├── 007-Relational-Model.pdf │ ├── 008-Keys.pdf │ ├── 009-Integrity-Rules-And-Constraints.pdf │ ├── 010-Relational-Algebra.pdf │ ├── 011-MySQL-Install-Linux.pdf │ ├── 011-MySQL-Install-MacOS.pdf │ ├── 011-MySQL-Install-Windows.pdf │ ├── 012-SQL-Quick-Summary.pdf │ ├── 013-SQL-Datatypes-Summary.pdf │ ├── 014-SQL-Commands-Summary.pdf │ ├── 015-Filtering-And-Sorting-Data.pdf │ ├── 016-Grouping-Data-Summary.pdf │ ├── 017-Queries-Tables-Constraints.pdf │ ├── 018-Modifying-Data.pdf │ ├── 019-Joining-Tables.pdf │ ├── 020-Set-Operations.pdf │ ├── 021-SubQuery-And-Types.pdf │ ├── 022-SubQuery-Examples.pdf │ ├── 023-Joins-Vs-Subqueries.pdf │ ├── 024-Transaction-Statement.pdf │ ├── 025-Import-Export.pdf │ ├── 026-Functional-Dependency.pdf │ ├── 027-Anomalies.pdf │ ├── 028-Normalisation-1.pdf │ ├── 028-Normalisation-2.pdf │ ├── 029-Transaction-ACID-Properties.pdf │ ├── 030-Transaction-States.pdf │ ├── 031-Indexing-1.pdf │ ├── 031-Indexing-2.pdf │ ├── 032-Advantages-Disadvantages-NoSQL.pdf │ ├── 033-Key-Value-NoSQL-DB.pdf │ ├── 034-Columnar-NoSQL-DB.pdf │ ├── 035-Document-NoSQL-DB.pdf │ ├── 036-Graph-Based-NoSQL-DB.pdf │ ├── 037-Relational-Database.pdf │ ├── 038-Object-Oriented-Database.pdf │ ├── 039-Hierarchical-Database.pdf │ ├── 040-Network-Database.pdf │ ├── 041-Concurrency-Control.pdf │ ├── 042-Clustering.pdf │ ├── 043-Partitioning-Sharding.pdf │ └── 044-Imp-Functions-And-Commands.pdf └── code │ ├── 001-Introduction-to-dbms.cpp │ ├── 002-Data-Models.cpp │ ├── 003-ER-Model.cpp │ ├── 004-Relational-Models.cpp │ ├── 005-Intro-To-SQL.cpp │ ├── 006-SQL-Datatypes.cpp │ ├── 007-SQL-Commands.cpp │ ├── 008-Filtering-And-Sorting-Data.cpp │ ├── 009-Grouping-Data.cpp │ ├── 010-Query-Table-And-Constraints.cpp │ ├── 011-Modifying-Data.cpp │ ├── 012-Joining-Tables.cpp │ ├── 013-Set-Operations.cpp │ ├── 014-Sub-Queries.cpp │ ├── 015-Managing-Databases.cpp │ ├── 016-Transaction-Statement.cpp │ ├── 017-Import-Export.cpp │ ├── 018-Normalization.cpp │ ├── 019-Transaction.cpp │ ├── 020-Indexing.cpp │ ├── 021-NOSQL.cpp │ ├── 022-Database-Types.cpp │ ├── 023-Database-Optimization.cpp │ └── 024-SQL-Query-Assessment.cpp ├── 08-curated-interview-dsa-problems-java ├── README.md └── modules │ └── 001-array │ ├── README.md │ └── code │ ├── P001_Rearrange_In_ZigZag_Order.java │ ├── P002_4th_Highest_element.java │ ├── P003_Max_Profit_Selling_Gulal.java │ ├── P004_Buying_And_Selling_Stocks.java │ ├── P005_Divide_In_Three_Way.java │ ├── P006_Non_Decreasing_Array_Convertible.java │ ├── P007_Trapped_Water_In_Bars.java │ ├── P008_Subarray_Sum_Of_Infinite_Array.java │ ├── P009_Ninja_Vs_Board.java │ └── P010_Design_Browser_History.java ├── Contributing.md ├── README.md └── pre-placement-checklist-questions.pdf /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Mac", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "/usr/local/include", 8 | "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1", 9 | "/Library/Developer/CommandLineTools/usr/lib/clang/16/include", 10 | "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include", 11 | "/Library/Developer/CommandLineTools/usr/include", 12 | "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks" 13 | ], 14 | "defines": [], 15 | "macFrameworkPath": [ 16 | "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks" 17 | ], 18 | "compilerPath": "/usr/bin/clang++", 19 | "cStandard": "c17", 20 | "cppStandard": "c++98", 21 | "intelliSenseMode": "macos-clang-arm64" 22 | } 23 | ], 24 | "version": 4 25 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/001-basics/README.md: -------------------------------------------------------------------------------- 1 | # Introduction to C++ 2 | 3 | > **C++** is a **general-purpose programming language** that was developed as an enhancement of the C language to include **object-oriented paradigm**. It is an imperative and a compiled language. 4 | 5 | --- 6 | 7 | ### Notes 8 | 9 | - [Click here for Flow Charts](./assets/FlowCharts.pdf)
10 | - [Click here for Basics - Variables, IO, Operators](./assets/Basics-Variables-IO.pdf)
11 | - [Click here for Conditionals, Loops](./assets/FlowCharts.pdf)
12 | - [Click here for Functions](./assets/FlowCharts.pdf)
13 | 14 | --- 15 | 16 | ## Problems - Code in Action 17 | 18 | [001 - Introduction to C++](./code/001-C++-Intro.cpp)
19 | [002 - Datatypes](./code/002-Datatype.cpp)
20 | [003 - Input / Output](./code/003-IO.cpp)
21 | [004 - Operators - Arithmetic, Relational, Logical](./code/004-Oper-Arithmatic-Relational-Logical.cpp)
22 | [005 - Operators - Bitwise](./code/005-Oper-Bitwise.cpp)
23 | [006 - Conditions](./code/006-Conditions.cpp)
24 | [007 - Functions](./code/007-Functions.cpp)
-------------------------------------------------------------------------------- /01-introduction-to-c++/modules/001-basics/assets/Basics-Variables-IO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/01-introduction-to-c++/modules/001-basics/assets/Basics-Variables-IO.pdf -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/001-basics/assets/Conditionals-Loops.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/01-introduction-to-c++/modules/001-basics/assets/Conditionals-Loops.pdf -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/001-basics/assets/FlowCharts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/01-introduction-to-c++/modules/001-basics/assets/FlowCharts.pdf -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/001-basics/assets/Functions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/01-introduction-to-c++/modules/001-basics/assets/Functions.pdf -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/001-basics/code/007-Functions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | //function for increment 5 | void increment(int a){ 6 | a = a+1; 7 | } 8 | 9 | int main(){ 10 | 11 | //Pass by value function 12 | // When increment function is called - n is copied to a . So that value of n remain 13 | int n=10; 14 | increment(n); 15 | cout << n << endl; 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/assets/Conditionals-And-Loops.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/01-introduction-to-c++/modules/002-loops/assets/Conditionals-And-Loops.pdf -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/assets/Operators-And-For-Loop.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/01-introduction-to-c++/modules/002-loops/assets/Operators-And-For-Loop.pdf -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/assets/Patterns.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/01-introduction-to-c++/modules/002-loops/assets/Patterns.pdf -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-1/001-Check-Number-If-Prime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Check if the number provided is prime or not. 7 | */ 8 | void checkPrime(){ 9 | int num; 10 | cout << "Enter num : " << endl; 11 | cin >> num; 12 | 13 | int d = 2; 14 | bool flag = false; 15 | while(d < num ){ 16 | if(num % d == 0){ 17 | cout << "Not prime" << endl; 18 | flag = true; 19 | break; 20 | } 21 | d = d+1; 22 | } 23 | if(!flag){ 24 | cout << "Prime" << endl; 25 | } 26 | } 27 | 28 | int main(){ 29 | checkPrime(); 30 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-1/002-Sum-Of-Even-Numbers-Till-N.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Sum of Even Numbers till N 7 | * - Given a number N, print sum of all even numbers from 1 to N. 8 | * 9 | * Input Format : 10 | * Integer N 11 | * Output Format : 12 | * Required Sum 13 | * 14 | * Sample Input 1 : 15 | * 6 16 | * Sample Output 1 : 17 | * 12 18 | */ 19 | int main(){ 20 | int N; 21 | cin >> N; 22 | 23 | int sum = 0 , ptr = 2; 24 | while( ptr <= N ){ 25 | sum += ptr; 26 | ptr = ptr+2; 27 | } 28 | cout << sum << endl; 29 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-1/004-Number-Pattern-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Number Pattern 1 7 | * - Print the following pattern 8 | * - Pattern for N = 4 9 | * 1 10 | * 23 11 | * 345 12 | * 4567 13 | * 14 | * Input Format : 15 | * N (Total no. of rows) 16 | * Output Format : 17 | * Pattern in N lines 18 | * 19 | * Sample Input 1 : 20 | * 3 21 | * Sample Output 1 : 22 | * 1 23 | * 23 24 | * 345 25 | */ 26 | 27 | int main(){ 28 | int N; 29 | cin >> N; 30 | 31 | int i=1; 32 | while(i <= N){ 33 | int j = i, k =1; 34 | while(k <= i){ 35 | cout << j; 36 | j = j+1; 37 | k = k+1; 38 | } 39 | cout << endl; 40 | i = i+1; 41 | } 42 | 43 | } 44 | 45 | -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-1/005-Number-Pattern-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * Number Pattern 2 6 | * - Print the following pattern 7 | * - Pattern for N = 4 8 | * 1 9 | * 23 10 | * 345 11 | * 4567 12 | * 13 | * Input Format : 14 | * N (Total no. of rows) 15 | * Output Format : 16 | * Pattern in N lines 17 | * 18 | * Sample Input : 19 | * 5 20 | * Sample Output : 21 | * 1 22 | * 23 23 | * 345 24 | * 4567 25 | * 56789 26 | */ 27 | 28 | int main() { 29 | int N; 30 | cin >> N; 31 | 32 | int i=1; 33 | while(i <= N){ 34 | int l = 1; 35 | while(l <= N-i){ 36 | cout << " "; 37 | l = l+1; 38 | } 39 | int j=i, k=1; 40 | while(k <= i){ 41 | cout << j; 42 | j = j+1; 43 | k = k+1; 44 | } 45 | cout << endl; 46 | i = i+1; 47 | } 48 | 49 | return 0; 50 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-1/006-Star-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Start Pattern 7 | * - Print the following pattern 8 | * 9 | * Input Format : 10 | * N (Total no. of rows) 11 | * Output Format : 12 | * Pattern in N lines 13 | * 14 | * Constraints : 15 | * 0 <= N <= 50 16 | * 17 | * Sample Input 1 18 | * 3 19 | * Sample Output 1 : 20 | * * 21 | * *** 22 | * ***** 23 | * 24 | * Sample Input 2 : 25 | * 4 26 | * Sample Output 2 : 27 | * * 28 | * *** 29 | * ***** 30 | * ******* 31 | */ 32 | 33 | int main() { 34 | int N; 35 | cin >> N; 36 | 37 | int i =1; 38 | while(i <= N){ 39 | int j = 1; 40 | while(j <= N-i){ 41 | cout << " "; 42 | j = j+1; 43 | } 44 | int k = 1; 45 | while(k <= 2*i-1){ 46 | cout << "*"; 47 | k = k+1; 48 | } 49 | cout << endl; 50 | i = i+1; 51 | } 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-1/009-Find-Power-Of-Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Find Power of Number 7 | * - Write a program to find x to the power n (i.e. x^n). Take x and n from the 8 | * user. You need to print the answer. 9 | * Note : For this question, you can assume that 0 raised to the power of 0 is 1 10 | * 11 | * Input format : 12 | * Two integers x and n (separated by space) 13 | * Output Format : 14 | * x^n (i.e. x raise to the power n) 15 | * 16 | * Constraints: 17 | * 0 <= x <= 8 18 | * 0 <= n <= 9 19 | * 20 | * Sample Input 1 : 21 | * 3 4 22 | * Sample Output 1 : 23 | * 81 24 | * 25 | * Sample Input 2 : 26 | * 2 5 27 | * Sample Output 2 : 28 | * 32 29 | */ 30 | 31 | int main() { 32 | int x, n; 33 | cin >> x >> n ; 34 | 35 | int i=0, result = 1; 36 | while( i < n){ 37 | result *= x; 38 | i = i+1; 39 | } 40 | cout << result << endl; 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-2/001-Square-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Sqaure Pattern: 7 | * - Print the following pattern for the given N number of rows. 8 | * 9 | * Pattern for N = 4 10 | * 4444 11 | * 4444 12 | * 4444 13 | * 4444 14 | * 15 | * Input format : 16 | * Integer N (Total no. of rows) 17 | * Output format : 18 | * Pattern in N lines 19 | * 20 | * Constraints 21 | * 0 <= N <= 50 22 | * 23 | * Sample Input 1: 24 | * 7 25 | * Sample Output 1: 26 | * 7777777 27 | * 7777777 28 | * 7777777 29 | * 7777777 30 | * 7777777 31 | * 7777777 32 | * 7777777 33 | * 34 | * Sample Input 1: 35 | * 6 36 | * Sample Output 1: 37 | * 666666 38 | * 666666 39 | * 666666 40 | * 666666 41 | * 666666 42 | * 666666 43 | */ 44 | int main() { 45 | int N; 46 | cin >> N; 47 | 48 | int i=1; 49 | while(i<=N){ 50 | int j = 1; 51 | while(j <= N){ 52 | cout << N; 53 | j++; 54 | } 55 | cout< 2 | using namespace std; 3 | 4 | /** 5 | * Triangular star Pattern 6 | * - Print the following pattern for the given N number of rows. 7 | * - Pattern for N = 4 8 | * * 9 | * ** 10 | * *** 11 | * **** 12 | * Note : There are no spaces between the stars (*). 13 | * 14 | * Input format : 15 | * Integer N (Total no. of rows) 16 | * Output format : 17 | * Pattern in N lines 18 | * 19 | * Constraints 20 | * 0 <= N <= 50 21 | * 22 | * Sample Input 1: 23 | * 5 24 | * Sample Output 1: 25 | * * 26 | * ** 27 | * *** 28 | * **** 29 | * ***** 30 | * 31 | * Sample Input 2: 32 | * 6 33 | * Sample Output 2: 34 | * * 35 | * ** 36 | * *** 37 | * **** 38 | * ***** 39 | * ****** 40 | */ 41 | int main(){ 42 | int N; 43 | cin >> N; 44 | 45 | int i=1; 46 | while(i <= N){ 47 | int j = 1; 48 | while(j <= i){ 49 | cout << "*"; 50 | j = j+1; 51 | } 52 | cout << endl; 53 | i++; 54 | } 55 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-2/003-Triangle-Number-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Triangle Number Pattern 7 | * - Print the following pattern for the given N number of rows. 8 | * - Pattern for N = 4 9 | * 1 10 | * 22 11 | * 333 12 | * 4444 13 | * 14 | * Input format : 15 | * Integer N (Total no. of rows) 16 | * Output format : 17 | * Pattern in N lines 18 | * 19 | * Constraints 20 | * 0 <= N <= 50 21 | * 22 | * Sample Input 1: 23 | * 5 24 | * Sample Output 1: 25 | * 1 26 | * 22 27 | * 333 28 | * 4444 29 | * 55555 30 | * 31 | * Sample Input 2: 32 | * 6 33 | * Sample Output 2: 34 | * 1 35 | * 22 36 | * 333 37 | * 4444 38 | * 55555 39 | * 666666 40 | */ 41 | 42 | int main() { 43 | int N; 44 | cin >> N; 45 | 46 | int i=1; 47 | while(i <= N){ 48 | int j = 1; 49 | while(j <= i){ 50 | cout << i; 51 | j++; 52 | } 53 | cout << endl; 54 | i++; 55 | } 56 | 57 | return 0; 58 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-2/004-Reverse-Number-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Reverse Number pattern 7 | * - Print the following pattern for the given N number of rows. 8 | * - Pattern for N = 4 9 | * 1 10 | * 21 11 | * 321 12 | * 4321 13 | * 14 | * Input format : 15 | * Integer N (Total no. of rows) 16 | * Output format : 17 | * Pattern in N lines 18 | * 19 | * Constraints 20 | * 0 <= N <= 50 21 | * 22 | * Sample Input 1: 23 | * 5 24 | * Sample Output 1: 25 | * 1 26 | * 21 27 | * 321 28 | * 4321 29 | * 54321 30 | * 31 | * Sample Input 2: 32 | * 6 33 | * Sample Output 2: 34 | * 1 35 | * 21 36 | * 321 37 | * 4321 38 | * 54321 39 | * 654321 40 | */ 41 | 42 | int main(){ 43 | int N; 44 | cin >> N; 45 | 46 | int i=1; 47 | while(i <= N){ 48 | int j = 1; 49 | while(j <= i){ 50 | cout << i-j+1; 51 | j++; 52 | } 53 | cout << endl; 54 | i++; 55 | } 56 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-2/005-Character-Pattern-Basic.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * Character Pattern: 6 | * N = 4 ,print : 7 | * ABCD 8 | * ABCD 9 | * ABCD 10 | * ABCD 11 | */ 12 | void pattern1(){ 13 | int N; 14 | cin >> N; 15 | 16 | int i=1; 17 | while(i <= N){ 18 | int j=1; 19 | char startChar = 'A'; 20 | while(j <= N){ 21 | char ch = startChar + j -1; 22 | cout << ch; 23 | j++; 24 | } 25 | cout << endl; 26 | i++; 27 | } 28 | } 29 | 30 | /** 31 | * Character Pattern: 32 | * N = 4 ,print : 33 | * ABCD 34 | * BCDE 35 | * CDEF 36 | * DEFG 37 | */ 38 | void pattern2(){ 39 | int N; 40 | cin >> N; 41 | 42 | int i = 1; 43 | while(i <= N){ 44 | int j =1; 45 | char startChar = 'A' + i - 1; 46 | while(j <= N){ 47 | char ch = startChar + j - 1; 48 | cout << ch; 49 | j++; 50 | } 51 | cout << endl; 52 | i++; 53 | } 54 | } 55 | 56 | int main(){ 57 | pattern1(); 58 | pattern2(); 59 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-2/006-Alpha-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * Alpha Pattern 6 | * - Print the following pattern for the given N number of rows. 7 | * - Pattern for N = 3 8 | * A 9 | * BB 10 | * CCC 11 | * Input format : 12 | * Integer N (Total no. of rows) 13 | * Output format : 14 | * Pattern in N lines 15 | * 16 | * Constraints 17 | * 0 <= N <= 26 18 | * 19 | * Sample Input 1: 20 | * 7 21 | * Sample Output 1: 22 | * A 23 | * BB 24 | * CCC 25 | * DDDD 26 | * EEEEE 27 | * FFFFFF 28 | * GGGGGGG 29 | * 30 | * Sample Input 2: 31 | * 6 32 | * Sample Output 2: 33 | * A 34 | * BB 35 | * CCC 36 | * DDDD 37 | * EEEEE 38 | * FFFFFF 39 | */ 40 | int main(){ 41 | int N ; 42 | cin >> N; 43 | 44 | int i=1; 45 | while(i <= N){ 46 | int j=1; 47 | while(j <= i){ 48 | char ch = 'A' + i - 1; 49 | cout << ch; 50 | j++; 51 | } 52 | cout << endl; 53 | i++; 54 | } 55 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-2/007-Character-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Character Pattern 7 | * - Print the following pattern for the given N number of rows. 8 | * - Pattern for N = 4 9 | * A 10 | * BC 11 | * CDE 12 | * DEFG 13 | * Input format : 14 | * Integer N (Total no. of rows) 15 | * Output format : 16 | * Pattern in N lines 17 | * 18 | * Constraints 19 | * 0 <= N <= 13 20 | * 21 | * Sample Input 1: 22 | * 5 23 | * Sample Output 1: 24 | * A 25 | * BC 26 | * CDE 27 | * DEFG 28 | * EFGHI 29 | * 30 | * Sample Input 2: 31 | * 6 32 | * Sample Output 2: 33 | * A 34 | * BC 35 | * CDE 36 | * DEFG 37 | * EFGHI 38 | * FGHIJK 39 | */ 40 | int main(){ 41 | int N; 42 | cin >> N; 43 | 44 | int i=1; 45 | while(i <= N){ 46 | int j = 1; 47 | char startChar = 'A' + i -1; 48 | while(j <= i){ 49 | char ch = startChar + j - 1; 50 | cout << ch; 51 | j++; 52 | } 53 | cout << endl; 54 | i++; 55 | } 56 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-2/008-Interesting-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Interesting Alphabets 7 | * - Print the following pattern for the given number of rows. 8 | * - Pattern for N = 5 9 | * E 10 | * DE 11 | * CDE 12 | * BCDE 13 | * ABCDE 14 | * 15 | * Input format : 16 | * N (Total no. of rows) 17 | * Output format : 18 | * Pattern in N lines 19 | * Constraints 20 | * 0 <= N <= 26 21 | * 22 | * Sample Input 1: 23 | * 8 24 | * Sample Output 1: 25 | * H 26 | * GH 27 | * FGH 28 | * EFGH 29 | * DEFGH 30 | * CDEFGH 31 | * BCDEFGH 32 | * ABCDEFGH 33 | * 34 | * Sample Input 2: 35 | * 7 36 | * Sample Output 2: 37 | * G 38 | * FG 39 | * EFG 40 | * DEFG 41 | * CDEFG 42 | * BCDEFG 43 | * ABCDEFG 44 | */ 45 | int main(){ 46 | int N; 47 | cin >> N; 48 | 49 | int i=1; 50 | while(i <= N){ 51 | int j = 1; 52 | char startChar = 'A' + N - i; 53 | while(j <= i){ 54 | char ch = startChar + j - 1; 55 | cout << ch; 56 | j++; 57 | } 58 | cout << endl; 59 | i++; 60 | } 61 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-3/001-Reverse-Triangle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #include 5 | using namespace std; 6 | 7 | /** 8 | * Reverse Triangle 9 | * N=4 , 10 | * * 11 | * ** 12 | * *** 13 | * **** 14 | */ 15 | int main(){ 16 | int N; 17 | cin >> N; 18 | 19 | int i=1; 20 | while(i <= N){ 21 | int spaces = 1; 22 | while(spaces <= N - i){ 23 | cout << " "; 24 | spaces++; 25 | } 26 | int stars = 1; 27 | while(stars <= i){ 28 | cout << "*"; 29 | stars++; 30 | } 31 | cout << endl; 32 | i++; 33 | } 34 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-3/002-Mirror-Number-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Mirror Number Pattern 7 | * - Print the following pattern for the given N number of rows. 8 | * 9 | * Input format : 10 | * Integer N (Total no. of rows) 11 | * Output format : 12 | * Pattern in N lines 13 | * Constraints 14 | * 0 <= N <= 50 15 | * 16 | * Sample Input 1: 17 | * 3 18 | * Sample Output 1: 19 | * 1 20 | * 12 21 | * 123 22 | * 23 | * Sample Input 2: 24 | * 4 25 | * Sample Output 2: 26 | * 1 27 | * 12 28 | * 123 29 | * 1234 30 | */ 31 | int main(){ 32 | int N; 33 | cin >> N; 34 | 35 | int i=1; 36 | while(i <= N){ 37 | int spaces = 1; 38 | while(spaces <= N-i){ 39 | cout << " "; 40 | spaces++; 41 | } 42 | int j=1; 43 | while(j <= i){ 44 | cout << j; 45 | j++; 46 | } 47 | 48 | cout< 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Inverted Triangle 7 | * N=4, 8 | * **** 9 | * *** 10 | * ** 11 | * * 12 | */ 13 | int main(){ 14 | int N; 15 | cin >> N; 16 | 17 | int i=1; 18 | while(i <= N){ 19 | int j = 1; 20 | while(j <= N-i+1){ 21 | cout << "*"; 22 | j++; 23 | } 24 | 25 | cout << endl; 26 | i++; 27 | } 28 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-3/004-Inverted-Number-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Inverted Number Pattern 7 | * - Print the following pattern for the given N number of rows. 8 | * - Pattern for N = 4 9 | * 4444 10 | * 333 11 | * 22 12 | * 1 13 | * 14 | * Input format : 15 | * Integer N (Total no. of rows) 16 | * Output format : 17 | * Pattern in N lines 18 | * Constraints : 19 | * 0 <= N <= 50 20 | * 21 | * Sample Input 1: 22 | * 5 23 | * Sample Output 1: 24 | * 55555 25 | * 4444 26 | * 333 27 | * 22 28 | * 1 29 | * 30 | * Sample Input 2: 31 | * 6 32 | * Sample Output 2: 33 | * 666666 34 | * 55555 35 | * 4444 36 | * 333 37 | * 22 38 | * 1 39 | */ 40 | int main(){ 41 | int N; 42 | cin >> N; 43 | 44 | int i=1; 45 | while(i <= N){ 46 | int j = 1; 47 | while(j <= N-i+1){ 48 | cout << N-i+1; 49 | j++; 50 | } 51 | cout << endl; 52 | i++; 53 | } 54 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-3/005-Isoceles-Triangle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Isoceles Triangle 7 | * N=4, 8 | * 1 9 | * 121 10 | * 12321 11 | * 1234321 12 | */ 13 | int main(){ 14 | int N; 15 | cin >> N; 16 | 17 | int i=1; 18 | while(i <= N){ 19 | int j = 1; 20 | while(j <= N-i){ 21 | cout << " "; 22 | j++; 23 | } 24 | int k = 1; 25 | while(k <= i){ 26 | cout << k ; 27 | k++; 28 | } 29 | int l=i-1; 30 | while(l > 0){ 31 | cout << l; 32 | l--; 33 | } 34 | 35 | cout << endl; 36 | i++; 37 | } 38 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-3/006-Star-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * Star Pattern 6 | * - Print the following pattern 7 | * 8 | * Input Format : 9 | * N (Total no. of rows) 10 | * Output Format : 11 | * Pattern in N lines 12 | * 13 | * Constraints : 14 | * 0 <= N <= 50 15 | * 16 | * Sample Input 1 : 17 | * 3 18 | * Sample Output 1 : 19 | * * 20 | * *** 21 | * ***** 22 | * 23 | * Sample Input 2 : 24 | * 4 25 | * Sample Output 2 : 26 | * * 27 | * *** 28 | * ***** 29 | * ******* 30 | */ 31 | int main(){ 32 | int N; 33 | cin >> N; 34 | 35 | int i=1; 36 | while(i <= N){ 37 | int j = 1; 38 | while(j <= N-i){ 39 | cout << " "; 40 | j++; 41 | } 42 | int k =1; 43 | while(k <= 2*i - 1){ 44 | cout << "*"; 45 | k++; 46 | } 47 | 48 | cout << endl; 49 | i++; 50 | } 51 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-3/007-Triangle-Of-Numbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Triangle of Numbers 7 | * - Print the following pattern for the given number of rows. 8 | * 9 | * Input format : 10 | * Integer N (Total no. of rows) 11 | * Output format : 12 | * Pattern in N lines 13 | * 14 | * Constraints : 15 | * 0 <= N <= 50 16 | * 17 | * Sample Input 1: 18 | * 5 19 | * Sample Output 1: 20 | * 1 21 | * 232 22 | * 34543 23 | * 4567654 24 | * 567898765 25 | * 26 | * Sample Input 2: 27 | * 4 28 | * Sample Output 2: 29 | * 1 30 | * 232 31 | * 34543 32 | * 4567654 33 | */ 34 | int main(){ 35 | int N; 36 | cin >>N; 37 | 38 | int i = 1; 39 | while(i <= N){ 40 | int spaces = 1; 41 | while(spaces <= N-i){ 42 | cout << " "; 43 | spaces++; 44 | } 45 | int j = 1, m= i; 46 | while(j <= i){ 47 | cout << m; 48 | j++; 49 | m++; 50 | } 51 | int k = i-1, n = 2*(i-1); 52 | while(k > 0){ 53 | cout << n; 54 | n--; 55 | k--; 56 | } 57 | 58 | cout << endl; 59 | i++; 60 | } 61 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-3/009-Pattern-Medium-1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * N= 4, 6 | * 1 2 3 4 7 | * 9 10 11 12 8 | * 13 14 15 16 9 | * 5 6 7 8 10 | */ 11 | int main() 12 | { 13 | int n; 14 | cin >> n; 15 | 16 | // Write your code here 17 | int n1, n2; 18 | if(n%2 == 0){ 19 | n1 = n2 = n/2; 20 | } else { 21 | n1 = n/2+1; 22 | n2 = n/2; 23 | } 24 | 25 | int i=1; 26 | int num = 1; 27 | while(i <= n1){ 28 | int j = 1; 29 | while(j <= n){ 30 | cout << num << " "; 31 | num++; 32 | j++; 33 | } 34 | i++; 35 | num = num+n; 36 | cout<< endl; 37 | } 38 | 39 | if(n%2 == 0){ 40 | num = num - n; 41 | } else { 42 | num = num - 3*n; 43 | } 44 | 45 | int k= 1; 46 | while(k <= n2){ 47 | int j = 1; 48 | while(j <= n){ 49 | cout << num << " "; 50 | num++; 51 | j++; 52 | } 53 | num = num - 3*n; 54 | k++; 55 | cout << endl; 56 | } 57 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-4/002-All-Prime-Numers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * All Prime Numbers 7 | * - Given an integer N, print all the prime numbers that lie in the range 2 8 | * to N (both inclusive). 9 | * Print the prime numbers in different lines. 10 | * 11 | * Input Format : 12 | * Integer N 13 | * Output Format : 14 | * Prime numbers in different lines 15 | * 16 | * Constraints : 17 | * 1 <= N <= 100 18 | * 19 | * Sample Input 1: 20 | * 9 21 | * Sample Output 1: 22 | * 2 23 | * 3 24 | * 5 25 | * 7 26 | * 27 | * Sample Input 2: 28 | * 20 29 | * Sample Output 2: 30 | * 2 31 | * 3 32 | * 5 33 | * 7 34 | * 11 35 | * 13 36 | * 17 37 | * 19 38 | */ 39 | 40 | int main() { 41 | int N; 42 | cin >> N; 43 | 44 | for(int i = 2; i<=N; i++){ 45 | int j = i-1; 46 | while(j >= 2){ 47 | if(i%j == 0){ 48 | break; 49 | } 50 | j--; 51 | } 52 | if(j < 2){ 53 | cout << i << endl; 54 | } 55 | } 56 | 57 | return 0; 58 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-4/005-Terms-Of-AP.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Terms of AP 7 | * -> Write a program to print first x terms of the series 3N + 2 which are not 8 | * multiples of 4. 9 | * 10 | * Input format : 11 | * Integer x 12 | * Output format : 13 | * Terms of series (separated by space) 14 | * 15 | * Constraints : 16 | * 1 <= x <= 1,000 17 | * Sample Input 1 : 18 | * 10 19 | * Sample Output 1 : 20 | * 5 11 14 17 23 26 29 35 38 41 21 | * 22 | * Sample Input 2 : 23 | * 4 24 | * Sample Output 2 : 25 | * 5 11 14 17 26 | */ 27 | int main(){ 28 | int x; 29 | cin >> x; 30 | 31 | int N = 1, count = 0; 32 | while(count < x){ 33 | int num = 3*N + 2; 34 | if(num % 4 == 0){ 35 | N++; 36 | continue; 37 | } 38 | cout << num << " "; 39 | N++; 40 | count++; 41 | } 42 | cout << endl; 43 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-4/006-Reverse-Of-Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Reverse of a number 7 | * -> Write a program to generate the reverse of a given number N. Print the 8 | * corresponding reverse number. 9 | * Note : If a number has trailing zeros, then its reverse will not include 10 | * them. For e.g., reverse of 10400 will be 401 instead of 00401. 11 | * 12 | * Input format : 13 | * Integer N 14 | * Output format : 15 | * Corresponding reverse number 16 | * 17 | * Constraints: 18 | * 0 <= N < 10^8 19 | * 20 | * Sample Input 1 : 21 | * 1234 22 | * Sample Output 1 : 23 | * 4321 24 | * 25 | * Sample Input 2 : 26 | * 1980 27 | * Sample Output 2 : 28 | * 891 29 | */ 30 | int main(){ 31 | int N; 32 | cin >> N; 33 | 34 | int reverse = 0; 35 | while(N){ 36 | reverse = reverse*10 + N%10; 37 | N = N/10; 38 | } 39 | cout << reverse << endl; 40 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-4/007-Binary-To-Decimal.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Binary to decimal 7 | * -> Given a binary number as an integer N, convert it into decimal and print. 8 | * 9 | * Input format : 10 | * An integer N in the Binary Format 11 | * Output format : 12 | * Corresponding Decimal number (as integer) 13 | * 14 | * Constraints : 15 | * 0 <= N <= 10^9 16 | * 17 | * Sample Input 1 : 18 | * 1100 19 | * Sample Output 1 : 20 | * 12 21 | * 22 | * Sample Input 2 : 23 | * 111 24 | * Sample Output 2 : 25 | * 7 26 | */ 27 | int power(int n, int p){ 28 | int result = 1; 29 | for(int i=1; i<=p ; i++){ 30 | result *= n; 31 | } 32 | return result; 33 | } 34 | 35 | int main(){ 36 | int N; 37 | cin >> N; 38 | 39 | int i = 0, result = 0; 40 | while(N){ 41 | if(N%10 == 1){ 42 | result += power(2, i); 43 | } 44 | i++; 45 | N = N/10; 46 | } 47 | cout << result << endl; 48 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/002-loops/code-part-4/009-Square-Root-Integral.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Square Root (Integral) 7 | * -> Given a number N, find its square root. You need to find and print only 8 | * the integral part of square root of N. 9 | * For eg. if number given is 18, answer is 4. 10 | * 11 | * Input format : 12 | * Integer N 13 | * Output Format : 14 | * Square root of N (integer part only) 15 | * 16 | * Constraints : 17 | * 0 <= N <= 10^8 18 | * 19 | * Sample Input 1 : 20 | * 10 21 | * Sample Output 1 : 22 | * 3 23 | * 24 | * Sample Input 2 : 25 | * 4 26 | * Sample Output 2 : 27 | * 2 28 | */ 29 | int power(int n, int p){ 30 | int result = 1; 31 | for(int i=1; i<=p ; i++){ 32 | result *= n; 33 | } 34 | return result; 35 | } 36 | int main(){ 37 | int N; 38 | cin >> N; 39 | 40 | int i=1; 41 | while(power(i, 2) <= N){ 42 | i++; 43 | } 44 | cout << i-1 < Evaluation Time... 4 | 5 | --- 6 | 7 | ### Problems: 8 | [001 - Guess Output](./code/001-Guess-Output.cpp)
9 | [002 - Pyramid Star Pattern](./code/002-Pyramid-Star-Pattern.cpp)
10 | [003 - Number Star Pattern](./code/003-Number-Star-Pattern.cpp)
11 | [004 - Second largest](./code/004-Second-Largest.cpp)
12 | 13 | --- -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/003-test-1/code/001-Guess-Output.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * Find the output. 6 | * Ans : No Output 7 | */ 8 | void problem1(){ 9 | int p = 100; 10 | if(p > 20) { 11 | if(p < 20) { 12 | printf("coding"); 13 | } 14 | } else { 15 | printf("ninjas"); 16 | } 17 | } 18 | 19 | /** 20 | * Write the correct order(s) of statements. 21 | * We want to print "Coding Ninjas" 10 times. 22 | * 23 | * 1. while(x <= 10) { 24 | * 2. int x = 1; 25 | * 3. x += 1; 26 | * 4. print("Coding Ninjas\n"); 27 | * 5. } 28 | * 29 | * Ans : 2 1 3 4 5 30 | * 2 1 4 3 5 31 | */ 32 | 33 | /** 34 | * Figure out the output 35 | * Ans : 97531-1 36 | */ 37 | void problem3(){ 38 | int x = 10; 39 | while(x >= 0) { 40 | x = x - 1; 41 | printf("%d" , x); 42 | x--; 43 | } 44 | } 45 | 46 | int main(){ 47 | problem1(); 48 | problem3(); 49 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/003-test-1/code/002-Pyramid-Star-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Pyramid Number Pattern : Print the following pattern for the given number of rows. 7 | * N=4, 8 | * 1 9 | * 212 10 | * 32123 11 | * 4321234 12 | * 13 | * Input format : N (Total no. of rows) 14 | * Output format : Pattern in N lines 15 | * 16 | * Sample Input : 17 | * 5 18 | * Sample Output : 19 | * 1 20 | * 212 21 | * 32123 22 | * 4321234 23 | * 543212345 24 | */ 25 | 26 | int main(){ 27 | int N; 28 | cin >> N; 29 | 30 | int i=1; 31 | while(i <= N){ 32 | int j=1; 33 | while(j <= N-i){ 34 | cout << " "; 35 | j++; 36 | } 37 | 38 | int k=i; 39 | while(k>=1){ 40 | cout << k; 41 | k--; 42 | } 43 | int a=1 , b=2; 44 | while(a <= i-1){ 45 | cout << b; 46 | b++; 47 | a++; 48 | } 49 | 50 | i++; 51 | cout << endl; 52 | } 53 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/003-test-1/code/003-Number-Star-Pattern.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Number Star Pattern 7 | * - Print the following pattern for given number of rows. 8 | * N=5, 9 | * 1234554321 10 | * 1234**4321 11 | * 123****321 12 | * 12******21 13 | * 1********1 14 | */ 15 | 16 | int main(){ 17 | int N; 18 | cin >> N; 19 | 20 | int i=1; 21 | while(i <= N){ 22 | int j=1; 23 | while(j <= N-i+1){ 24 | cout << j; 25 | j++; 26 | } 27 | int k=1; 28 | while(k <= 2*i-2){ 29 | cout << "*"; 30 | k++; 31 | } 32 | int l=N-i+1; 33 | while(l >=1){ 34 | cout << l; 35 | l--; 36 | } 37 | 38 | i++; 39 | cout << endl; 40 | } 41 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/003-test-1/code/004-Second-Largest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Second Largest 7 | * - Take input a stream of n integer elements, find the second largest 8 | * element present. 9 | * - The given elements can contain duplicate elements as well. If only 10 | * 0 or 1 element is given, the second largest should be INT_MIN ( - 2^31 ). 11 | * 12 | * Input format : 13 | * Line 1 : Total number of elements (n) 14 | * Line 2 : N elements (separated by space) 15 | * 16 | * Sample Input 1: 17 | * 4 18 | * 3 9 0 9 19 | * Sample Output 1: 20 | * 3 21 | * 22 | * Sample Input 2 : 23 | * 2 24 | * 4 4 25 | * Sample Output 2: 26 | * -2147483648 27 | * Sample Output Explanation: 28 | * Since both the elements are equal here, hence second largest element 29 | * is INT_MIN i.e. ( -2^31 ) 30 | */ 31 | 32 | int main(){ 33 | int N; 34 | cin >> N; 35 | 36 | int largest = INT_MIN, second = INT_MIN; 37 | while(N){ 38 | int num; 39 | cin >> num; 40 | 41 | if(num > largest){ 42 | second = largest; 43 | largest = num; 44 | } else if( num != largest && num > second){ 45 | second = num; 46 | } 47 | N--; 48 | } 49 | cout << second; 50 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/004-arrays/assets/Arrays.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/01-introduction-to-c++/modules/004-arrays/assets/Arrays.pdf -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/004-arrays/assets/Character-And-2D-Arrays.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/01-introduction-to-c++/modules/004-arrays/assets/Character-And-2D-Arrays.pdf -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/004-arrays/code-part-1/001-Array-Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * Array Sum 6 | * - Given an array of length N, you need to find and print the sum of all 7 | * elements of the array. 8 | * 9 | * Input Format : 10 | * Line 1 : An Integer N i.e. size of array 11 | * Line 2 : N integers which are elements of the array, separated by spaces 12 | * Output Format : 13 | * Sum 14 | * 15 | * Constraints : 16 | * 1 <= N <= 10^6 17 | * 18 | * Sample Input : 19 | * 3 20 | * 9 8 9 21 | * Sample Output : 22 | * 26 23 | */ 24 | 25 | int main(){ 26 | int N; 27 | cin >> N; 28 | 29 | int array[N]; 30 | int i=0; 31 | while(i < N){ 32 | int num; 33 | cin >> num; 34 | 35 | array[i] = num; 36 | i++; 37 | } 38 | 39 | int sum=0; 40 | for(int i=0; i 2 | #include 3 | using namespace std; 4 | 5 | /** 6 | * 1-D Char array - String 7 | */ 8 | int main(){ 9 | char name[100]; 10 | cout << "Enter your name : "; 11 | cin >> name; 12 | cout << "Name : " << name << endl; 13 | name[4] = 'x'; 14 | cout << "Name : " << name << endl; 15 | name[3] = 'd' ; 16 | cout << "Name : " << name << endl; 17 | name[1] = '\0'; 18 | cout << "Name : " << name << endl; 19 | cout << "======================" << endl; 20 | 21 | char str[100]; 22 | cin.getline(str, 100); 23 | cout << "output string : "< 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Replace Character 7 | * - Given an input string S and two characters c1 and c2, you need to replace 8 | * every occurrence of character c1 with character c2 in the given string. 9 | * 10 | * Input Format : 11 | * Line 1 : Input String S 12 | * Line 2 : Character c1 and c2 (separated by space) 13 | * Output Format : 14 | * Updated string 15 | * 16 | * Constraints : 17 | * 1 <= Length of String S <= 10^6 18 | * 19 | * Sample Input : 20 | * abacd 21 | * a x 22 | * Sample Output : 23 | * xbxcd 24 | */ 25 | int length(char str[]){ 26 | int count = 0, i=0; 27 | while(str[i] != '\0'){ 28 | count++; 29 | i++; 30 | } 31 | return count; 32 | } 33 | void replaceCharacter(char input[], char c1, char c2) { 34 | int len = length(input), i=0; 35 | while(input[i] != '\0'){ 36 | if(input[i] == c1){ 37 | input[i] = c2; 38 | } 39 | i++; 40 | } 41 | } 42 | 43 | int main(){ 44 | char input[1000000]; 45 | char c1, c2; 46 | cin >> input; 47 | cin >> c1 >> c2; 48 | replaceCharacter(input, c1, c2); 49 | cout << input << endl; 50 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/004-arrays/code-part-2/005-Reverse-Word.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Reverse Word Wise: 7 | * -> Reverse the given string word wise. That is, the last word in given string should 8 | * come at 1st place, last second word at 2nd place and so on. Individual words should 9 | * remain as it is. 10 | */ 11 | int length(char input[]){ 12 | int count = 0; 13 | for(int i=0; input[i] != '\0'; i++){ 14 | count++; 15 | } 16 | return count; 17 | } 18 | void reverse(char *str, int i, int j){ 19 | while(i < j){ 20 | char ch=str[i]; 21 | str[i] = str[j]; 22 | str[j] = ch; 23 | i++; 24 | j--; 25 | } 26 | } 27 | void reverseStringWordWise(char input[]) { 28 | int len = length(input); 29 | reverse(input, 0 , len-1); 30 | int i=0; 31 | int start, end; 32 | while(input[i] != '\0'){ 33 | start=i; 34 | while(input[i] != ' ' && input[i] != '\0'){ 35 | i++; 36 | } 37 | end = i-1; 38 | reverse(input, start, end); 39 | i++; 40 | } 41 | } 42 | int main(){ 43 | char input[1000]; 44 | cin.getline(input, 1000); 45 | reverseStringWordWise(input); 46 | cout << input << endl; 47 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/004-arrays/code-part-3/001-Basic-2D-Arrays.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | //2-D array 5 | int main(){ 6 | int a[100][100]; 7 | int m, n; 8 | cin >> m >> n; 9 | 10 | //taking input 11 | for(int i=0; i> a[i][j]; 14 | } 15 | } 16 | 17 | //print array row wise 18 | cout << "Print array row wise : " << endl; 19 | for(int i=0; i 2 | using namespace std; 3 | 4 | /** 5 | * Column Wise Sum 6 | * - Given a 2D integer array of size M*N, find and print the sum of ith column elements 7 | * separated by space. 8 | * 9 | * Input Format : 10 | * First and only line of input contains M and N, followed by M * N space 11 | * separated integers representing the elements in the 2D array. 12 | * Output Format : 13 | * Sum of every ith column elements (separated by space) 14 | * Constraints : 15 | * 1 <= M, N <= 10^3 16 | * 17 | * Sample Input : 18 | * 4 2 1 2 3 4 5 6 7 8 19 | * Sample Output : 20 | * 16 20 21 | */ 22 | 23 | int main(){ 24 | int a[100][100]; 25 | int m,n; 26 | cin >> m >> n; 27 | //taking input 28 | for(int i=0; i> a[i][j]; 31 | } 32 | } 33 | // Print sum column wise 34 | int result[n]; 35 | for(int i=0; i **Searching** : finding out if element is present in the given array/list. 4 | 5 | > **Sorting** : It refers to the arrangement of elements in an ordered sequence either in increasing or decreasing order. 6 | 7 | --- 8 | 9 | ### Notes 10 | 11 | - [Click here for Notes for Searching & Sorting](./assets/Searching-And-Sorting.pdf)
12 | 13 | --- 14 | 15 | ## Problems 16 | 17 | [001 - Binary Search](./code/001-Binary-Search.cpp)
18 | [002 - Selection Sort](./code/002-Selection-Sort.cpp)
19 | [003 - Bubble Sort](./code/003-Bubble-Sort.cpp)
20 | [004 - Insertiion Sort](./code/004-Insertion-Sort.cpp)
21 | [005 - Merge Two Sorted Arrays](./code/005-Merge-Two-Sorted-Arrays.cpp)
22 | [006 - Push Zeros to End](./code/006-Push-Zeros-To-End.cpp)
23 | [007 - Rotate an Array](./code/007-Rotate-Array.cpp)
24 | [008 - Second Largest Element](./code/008-Second-Largest-Element.cpp)
25 | [009 - Check Array Rotation](./code/009-Check-Array-Rotation.cpp)
26 | [010 - Sort 0 1 2](./code/010-Sort-012.cpp)
27 | [011 - Sum of Two Arrays](./code/011-Sum-Of-Two-Arrays.cpp)
28 | 29 | --- -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/005-searching-sorting/assets/Searching-And-Sorting.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/01-introduction-to-c++/modules/005-searching-sorting/assets/Searching-And-Sorting.pdf -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/005-searching-sorting/code/002-Selection-Sort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | /** 10 | * Selection Sort: 11 | * 1. From all elements, go in loop and find the min. 12 | * 2. Put a pointer at start , and swap the min element with start index. 13 | * 3. increment the index . 14 | * 4. Repeat steps 1-3. 15 | */ 16 | void selectionSort(int* arr, int n){ 17 | for(int start=0; start> t; 34 | while (t--){ 35 | int size; 36 | cin >> size; 37 | int *input = new int[size]; 38 | for (int i = 0; i < size; ++i){ 39 | cin >> input[i]; 40 | } 41 | selectionSort(input, size); 42 | for (int i = 0; i < size; ++i){ 43 | cout << input[i] << " "; 44 | } 45 | delete[] input; 46 | cout << endl; 47 | } 48 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/006-string/README.md: -------------------------------------------------------------------------------- 1 | # string 2 | 3 | > **C++** has in its definition a way to represent sequence of characters as an object of class. This class is called **std::string** 4 | 5 | > **String** class stores the characters as a sequence of bytes with a functionality of allowing access to single byte character. 6 | 7 | --- 8 | 9 | ### string vs char array 10 | 11 | - A **character array** is simply an array of characters can terminated by a **null character**. A string is a class which defines objects that be represented as **stream of characters**. 12 | - Size of the character array has to allocated **statically**, more memory cannot be allocated at run time if required. Unused allocated memory is wasted in case of character array. In case of strings, memory is allocated **dynamically**. More memory can be allocated at run time on demand. As no memory is preallocated, no memory is wasted. 13 | - **Character array** do not offer much inbuilt functions to manipulate strings. **String** class defines a number of functionalities which allow manifold operations on strings. 14 | 15 | --- 16 | 17 | ### Problem - Code In Action 18 | 19 | [001 - String Basic](./code/001-Basics.cpp)
20 | [002 - Print All Substrings](./code/002-Print-All-Substrings.cpp)
21 | 22 | --- 23 | -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/006-string/code/001-Basics.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | //length 6 | char ch1[] = "Tarun is here"; 7 | cout << "length of the input string is : " << strlen(ch1) << endl; 8 | cout << "========================" << endl; 9 | 10 | //string compare 11 | char ch2[] = "Tarun"; 12 | char ch3[] = "Tarun1"; 13 | cout << "result of string compare : " << strcmp(ch2, ch3) << endl; 14 | cout << "========================" << endl; 15 | 16 | //string copy 17 | char ch4[100]; 18 | char ch5[] = "Tarun1"; 19 | strcpy(ch4, ch5); 20 | cout << "string ch4 : " << ch4 << endl; 21 | cout << "========================" << endl; 22 | 23 | //string copy 24 | char ch6[100] = "Varun"; 25 | char ch7[] = "Tarun1"; 26 | strncpy(ch6, ch7, 3); 27 | cout << "string ch6 : " << ch6 << endl; 28 | cout << "========================" << endl; 29 | return 0; 30 | } -------------------------------------------------------------------------------- /01-introduction-to-c++/modules/006-string/code/002-Print-All-Substrings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | /** 6 | * Print All Substrings 7 | * -> For a given input string(str), write a function to print all the possible substrings. 8 | */ 9 | void problem1(char input[]){ 10 | int len = strlen(input); 11 | for(int i=0; i Evaluation Time... 4 | 5 | --- 6 | 7 | ### Problems: 8 | [001 - Print 2D Array](./code/001-Print-2D-Array.cpp)
9 | [002 - Minimum Length Word](./code/002-Minimum-Length-Word.cpp)
10 | [003 - Largest In Array](./code/003-Leaders-In-Array.cpp)
11 | 12 | --- -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/001-basics/README.md: -------------------------------------------------------------------------------- 1 | # Basic - Pointers & Dynamic Memory 2 | 3 | > **Pointers** are one of the most important aspects of C++. **Pointers** are another type of variables which store the **address** of other variables. 4 | 5 | --- 6 | 7 | ### Detailed Notes for Pointer 8 | [Click here for Pointers Notes](./assets/pointers.pdf)
9 | 10 | --- 11 | 12 | ## Problems - Code In Action 13 | [001 - Pointers - Basics](./code/001-Basics-Pointers.cpp)
14 | [002 - Assignments - Pointer](./code/002-Assignments-Pointers.cpp)
15 | [003 - Type Casting](./code/003-Type-Casting.cpp)
16 | [004 - Dynamic Memory](./code/004-Dynamic-Memory.cpp)
17 | [005 - Pass By Reference](./code/005-Pass-By-Reference.cpp)
18 | [006 - Global Variables, Constants](./code/006-GlobalVariables-Constant.cpp)
19 | [007 - Vector Basics](./code/007-Vector-Usage.cpp)
20 | 21 | --- -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/001-basics/assets/pointers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/02-data-structure-algorithms/modules/001-basics/assets/pointers.pdf -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/001-basics/code/003-Type-Casting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | //typecasting 5 | void problem1(){ 6 | int i=65; 7 | char c=i; 8 | cout << "c : " << c << endl; // A 9 | cout<<"========================"< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | void print(vector v){ 13 | for(int i=0; i *vp= new vector(); 22 | delete vp; 23 | //static allocation 24 | vector v; 25 | v.push_back(10); 26 | v.push_back(20); 27 | v.push_back(30); 28 | v.push_back(40); 29 | 30 | //square brackets to be used for only get or update operation 31 | v[3] = 50; 32 | v[5] = 90; 33 | //v.push_back(70); 34 | //v.push_back(80); 35 | 36 | cout << "v[0] : " << v[0] << endl; 37 | //at is much safer than square brackets as we get error if we go out of range. 38 | cout << "v.at(3) : " << v.at(3) << endl; 39 | cout << "size : " << v.size() << endl; 40 | print(v); 41 | 42 | v.pop_back(); 43 | print(v); 44 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/assets/Recursion.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/02-data-structure-algorithms/modules/002-recursion/assets/Recursion.pdf -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/001-Factorial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * Works on thre principle of mathematical induction. 6 | * 1. Prove that F(0) , F(1) true. 7 | * 2. Assume that F(K) is true. 8 | * 3. Prove that F(K+1) is true. 9 | * 10 | * For Recusrsion problems: 11 | * 1. Write base case. 12 | * 2. Assume it will work for smaller problem. 13 | * 3. Solve big problem using the smaller problem output. 14 | */ 15 | int factorial(int n){ 16 | if(n == 0){ 17 | return 1; 18 | } 19 | int smallerOutput = factorial(n-1); 20 | return n*smallerOutput; 21 | } 22 | 23 | int main(){ 24 | int n; 25 | cin >> n; 26 | cout << factorial(n) << endl; 27 | cout<<"========================"< 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Power 7 | * - Write a program to find x to the power n (i.e. x^n). Take x and n from the user. 8 | * - You need to return the answer. Do this recursively. 9 | * 10 | * Input format : 11 | * Two integers x and n (separated by space) 12 | * Output Format : 13 | * x^n (i.e. x raise to the power n) 14 | * 15 | * Constraints : 16 | * 1 <= x <= 30 17 | * 0 <= n <= 30 18 | * 19 | * Sample Input 1 : 20 | * 3 4 21 | * Sample Output 1 : 22 | * 81 23 | * 24 | * Sample Input 2 : 25 | * 2 5 26 | * Sample Output 2 : 27 | * 32 28 | */ 29 | int power(int x, int n) { 30 | if(n==0){ 31 | return 1; 32 | } 33 | return x*power(x, n-1); 34 | } 35 | 36 | int main(){ 37 | int x, n; 38 | cin >> x >> n; 39 | cout << power(x, n) << endl; 40 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/003-Print-Numbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Print Numbers: 7 | * - Given is the code to print numbers from 1 to n in increasing order 8 | * recursively. But it contains few bugs that you need to rectify such 9 | * that all the test cases pass. 10 | * 11 | * Input Format : 12 | * Integer n 13 | * Output Format : 14 | * Numbers from 1 to n (separated by space) 15 | * Constraints : 16 | * 1 <= n <= 10000 17 | * 18 | * Sample Input 1 : 19 | * 6 20 | * Sample Output 1 : 21 | * 1 2 3 4 5 6 22 | * 23 | * Sample Input 2 : 24 | * 4 25 | * Sample Output 2 : 26 | * 1 2 3 4 27 | */ 28 | void print(int n){ 29 | if(n == 1){ 30 | cout << n << " "; 31 | return; 32 | } 33 | print(n - 1); 34 | cout << n << " "; 35 | } 36 | 37 | int main(){ 38 | int n; 39 | cin >> n; 40 | print(n); 41 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/004-Number-Of-Digits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Number of Digits: 7 | * - Given the code to find out and return the number of digits present in a 8 | * number recursively. But it contains few bugs, that you need to rectify 9 | * such that all the test cases should pass. 10 | * 11 | * Input Format : 12 | * Integer n 13 | * Output Format : 14 | * Count of digits 15 | * 16 | * Constraints : 17 | * 1 <= n <= 10^6 18 | * 19 | * Sample Input 1 : 20 | * 156 21 | * Sample Output 1 : 22 | * 3 23 | * 24 | * Sample Input 2 : 25 | * 7 26 | * Sample Output 2 : 27 | * 1 28 | */ 29 | int count(int n){ 30 | if(n == 0){ 31 | return 0; 32 | } 33 | int smallAns = count(n / 10); 34 | return smallAns + 1; 35 | } 36 | 37 | int main(){ 38 | int n; 39 | cin >> n; 40 | cout << count(n) << endl; 41 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/005-Nth-Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * Nth Fibinacci Number 6 | */ 7 | int fib(int n){ 8 | if(n==0){ 9 | return 0; 10 | } 11 | if(n==1){ 12 | return 1; 13 | } 14 | int smallerOutput1 = fib(n-1); 15 | int smallerOutput2 = fib(n-2); 16 | return smallerOutput1 + smallerOutput2; 17 | } 18 | 19 | int main(){ 20 | int n; 21 | cin >> n; 22 | cout << fib(n) << endl; 23 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/006-Check-If-Array-Is-Sorted.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Check if array is sorted or not 7 | */ 8 | bool isArraySorted(int arr[], int size){ 9 | if(size == 0 || size == 1){ 10 | return true; 11 | } 12 | if(arr[0] > arr[1]){ 13 | return false; 14 | } 15 | return isArraySorted(arr+1, size-1); 16 | } 17 | 18 | int main(){ 19 | int n; 20 | cin >> n; 21 | int arr[n]; 22 | for(int i=0; i> arr[i]; 24 | } 25 | cout << isArraySorted(arr, n) << endl; 26 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/007-Sum-Of-Array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Sum of Array: 7 | * - Given an array of length N, you need to find and return the sum of 8 | * all elements of the array. Do it recursively. 9 | * 10 | * Input Format : 11 | * Line 1 : An Integer N i.e. size of array 12 | * Line 2 : N integers which are elements of the array, separated by spaces 13 | * Output Format : 14 | * Sum 15 | * 16 | * Constraints : 17 | * 1 <= N <= 10^3 18 | * 19 | * Sample Input 1 : 20 | * 3 21 | * 9 8 9 22 | * Sample Output 1 : 23 | * 26 24 | * 25 | * Sample Input 2 : 26 | * 3 27 | * 4 2 1 28 | * Sample Output 2 : 29 | * 7 30 | */ 31 | int sum(int input[], int n) { 32 | if(n == 0){ 33 | return 0; 34 | } 35 | int smallerOutput = sum(input+1, n-1); 36 | return input[0] + smallerOutput; 37 | } 38 | 39 | int main(){ 40 | int n; 41 | cin >> n; 42 | int *input = new int[n]; 43 | for(int i = 0; i < n; i++) { 44 | cin >> input[i]; 45 | } 46 | cout << sum(input, n) << endl; 47 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/012-Multiplication-Recursive.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Multiplication (Recursive) 7 | * - Given two integers M & N, calculate and return their multiplication 8 | * using recursion. 9 | * - You can only use subtraction and addition for your calculation. No 10 | * other operators are allowed. 11 | * 12 | * Input format : 13 | * Line 1 : Integer M 14 | * Line 2 : Integer N 15 | * Output format : 16 | * M x N 17 | * Constraints : 18 | * 0 <= M <= 1000 19 | * 0 <= N <= 1000 20 | * 21 | * Sample Input 1 : 22 | * 3 23 | * 5 24 | * Sample Output 1 : 25 | * 15 26 | * 27 | * Sample Input 2 : 28 | * 4 29 | * 0 30 | * Sample Output 2 : 31 | * 0 32 | */ 33 | int multiplyNumbers(int m, int n) { 34 | if(n == 0){ 35 | return 0; 36 | } 37 | return m+multiplyNumbers(m, n-1); 38 | } 39 | 40 | int main(){ 41 | int m, n; 42 | cin >> m >> n; 43 | cout << multiplyNumbers(m, n) << endl; 44 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/013-Count-Zeros.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Count Zeros 7 | * - Given an integer N, count and return the number of zeros that are present 8 | * in the given integer using recursion. 9 | * 10 | * Input Format : 11 | * Integer N 12 | * Output Format : 13 | * Number of zeros in N 14 | * Constraints : 15 | * 0 <= N <= 10^9 16 | * 17 | * Sample Input 1 : 18 | * 0 19 | * Sample Output 1 : 20 | * 1 21 | * 22 | * Sample Input 2 : 23 | * 00010204 24 | * Sample Output 2 : 25 | * 2 26 | * Explanation for Sample Output 2 : 27 | * Even though "00010204" has 5 zeros, the output would still be 2 because 28 | * when you convert it to an integer, it becomes 10204. 29 | * 30 | * Sample Input 3 : 31 | * 708000 32 | * Sample Output 3 : 33 | * 4 34 | */ 35 | int countZeros(int n) { 36 | if(n<10){ 37 | if(n==0){ 38 | return 1; 39 | } 40 | return 0; 41 | } 42 | int ans = countZeros(n/10); 43 | if(n%10 == 0){ 44 | return ans+1; 45 | } 46 | return ans; 47 | } 48 | 49 | int main() { 50 | int n; 51 | cin >> n; 52 | cout << countZeros(n) << endl; 53 | } 54 | -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/014-Geometric-Sum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | /** 8 | * Geometric Sum 9 | * - Given k, find the geometric sum i.e. 10 | * 1 + 1/2 + 1/4 + 1/8 + ... + 1/(2^k) 11 | * 12 | * Input format : 13 | * Integer k 14 | * Output format : 15 | * Geometric sum (upto 5 decimal places) 16 | * Constraints : 17 | * 0 <= k <= 1000 18 | * 19 | * Sample Input 1 : 20 | * 3 21 | * Sample Output 1 : 22 | * 1.87500 23 | * 24 | * Sample Input 2 : 25 | * 4 26 | * Sample Output 2 : 27 | * 1.93750 28 | */ 29 | double geometricSum(int k) { 30 | if(k == 0){ 31 | return 1; 32 | } 33 | double ans = geometricSum(k-1); 34 | return ans+ 1/pow(2,k); 35 | } 36 | void assignment3() { 37 | int k; 38 | cin >> k; 39 | cout << fixed << setprecision(5); 40 | cout << geometricSum(k) << endl; 41 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/015-Check-Palindrome.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Check Palindrome (recursive) 7 | * - Check whether a given String S is a palindrome using recursion. 8 | * Return true or false. 9 | * 10 | * Input Format : 11 | * String S 12 | * Output Format : 13 | * 'true' or 'false' 14 | * Constraints : 15 | * 0 <= |S| <= 1000 16 | * where |S| represents length of string S. 17 | * 18 | * Sample Input 1 : 19 | * racecar 20 | * Sample Output 1: 21 | * true 22 | * 23 | * Sample Input 2 : 24 | * ninja 25 | * Sample Output 2: 26 | * false 27 | */ 28 | bool isPalindrome(char input[], int start , int end){ 29 | if(start > end){ 30 | return true; 31 | } 32 | if(input[start] != input[end]){ 33 | return false; 34 | } 35 | return isPalindrome(input, start+1, end-1); 36 | } 37 | bool checkPalindrome(char input[]) { 38 | int len = strlen(input); 39 | int start = 0, end = len-1; 40 | return isPalindrome(input, start, end); 41 | } 42 | 43 | int main(){ 44 | char input[50]; 45 | cin >> input; 46 | if(checkPalindrome(input)) { 47 | cout << "true" << endl; 48 | } 49 | else { 50 | cout << "false" << endl; 51 | } 52 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-1/016-Sum-Of-Digits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Sum of digits (recursive) 7 | * - Write a recursive function that returns the sum of the digits of a given integer. 8 | * 9 | * Input format : 10 | * Integer N 11 | * Output format : 12 | * Sum of digits of N 13 | * 14 | * Constraints : 15 | * 0 <= N <= 10^9 16 | * 17 | * Sample Input 1 : 18 | * 12345 19 | * Sample Output 1 : 20 | * 15 21 | * 22 | * Sample Input 2 : 23 | * 9 24 | * Sample Output 2 : 25 | * 9 26 | */ 27 | int sumOfDigits(int n) { 28 | if(n == 0){ 29 | return 0; 30 | } 31 | int ans = sumOfDigits(n/10); 32 | return ans + n%10; 33 | } 34 | 35 | int main() { 36 | int n; 37 | cin >> n; 38 | cout << sumOfDigits(n) << endl; 39 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-2/002-Remove-X.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Remove X 7 | * - Given a string, compute recursively a new string where all 'x' chars 8 | * have been removed. 9 | * 10 | * Input format : 11 | * String S 12 | * Output format : 13 | * Modified String 14 | * 15 | * Constraints : 16 | * 1 <= |S| <= 10^3 17 | * where |S| represents the length of string S. 18 | * 19 | * Sample Input 1 : 20 | * xaxb 21 | * Sample Output 1: 22 | * ab 23 | * 24 | * Sample Input 2 : 25 | * abc 26 | * Sample Output 2: 27 | * abc 28 | * 29 | * Sample Input 3 : 30 | * xx 31 | * Sample Output 3: 32 | * 33 | */ 34 | void removeX(char input[]) { 35 | if(input[0] == '\0'){ 36 | return; 37 | } 38 | removeX(input+1); 39 | if(input[0] == 'x'){ 40 | int len=strlen(input); 41 | int i; 42 | for(i=0; i 2 | #include 3 | 4 | using namespace std; 5 | 6 | /** 7 | * String to Integer 8 | * - Write a recursive function to convert a given string into the number 9 | * it represents. That is input will be a numeric string that contains 10 | * only numbers, you need to convert the string into corresponding integer 11 | * and return the answer. 12 | * 13 | * Input format : 14 | * Numeric string S (string, Eg. "1234") 15 | * Output format : 16 | * Corresponding integer N (int, Eg. 1234) 17 | * Constraints : 18 | * 0 <= |S| <= 9 19 | * where |S| represents length of string S. 20 | * 21 | * Sample Input 1 : 22 | * 00001231 23 | * Sample Output 1 : 24 | * 1231 25 | * 26 | * Sample Input 2 : 27 | * 12567 28 | * Sample Output 2 : 29 | * 12567 30 | */ 31 | int stringToNumber(char input[]) { 32 | if(input[0]== '\0'){ 33 | return 0; 34 | } 35 | int ans = stringToNumber(input+1); 36 | int len = strlen(input); 37 | return ((input[0]-48) * pow(10, len-1)) + ans; 38 | } 39 | 40 | int main(){ 41 | char input[50]; 42 | cin >> input; 43 | cout << stringToNumber(input) << endl; 44 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-2/004-Pair-Star.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Pair Star 7 | * - Given a string S, compute recursively a new string where identical 8 | * chars that are adjacent in the original string are separated from 9 | * each other by a "*". 10 | * 11 | * Input format : 12 | * String S 13 | * Output format : 14 | * Modified string 15 | * Constraints : 16 | * 0 <= |S| <= 1000 17 | * where |S| represents length of string S. 18 | * 19 | * Sample Input 1 : 20 | * hello 21 | * Sample Output 1: 22 | * hel*lo 23 | * 24 | * Sample Input 2 : 25 | * aaaa 26 | * Sample Output 2 : 27 | * a*a*a*a 28 | */ 29 | void pairStar(char input[]) { 30 | if(input[0] == '\0'){ 31 | return; 32 | } 33 | pairStar(input+1); 34 | if(input[0] == input[1]){ 35 | int len = strlen(input); 36 | input[len+1] ='\0'; 37 | int i; 38 | for( i=len;i>1; i--){ 39 | input[i] = input[i-1]; 40 | } 41 | input[i] = '*'; 42 | } 43 | } 44 | 45 | int main(){ 46 | char input[100]; 47 | cin.getline(input, 100); 48 | pairStar(input); 49 | cout << input << endl; 50 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-2/006-Replace-Character-recursive.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * Replace Character Recursively 6 | * - Given an input string S and two characters c1 and c2, you need to 7 | * replace every occurrence of character c1 with character c2 in the 8 | * given string. 9 | * 10 | * Input Format : 11 | * Line 1 : Input String S 12 | * Line 2 : Character c1 and c2 (separated by space) 13 | * Output Format : 14 | * Updated string 15 | * Constraints : 16 | * 1 <= Length of String S <= 10^6 17 | * 18 | * Sample Input : 19 | * abacd 20 | * a x 21 | * Sample Output : 22 | * xbxcd 23 | */ 24 | void replaceCharacter(char input[], char c1, char c2) { 25 | if(input[0] == '\0'){ 26 | return; 27 | } 28 | if(input[0] == c1){ 29 | input[0] = c2; 30 | } 31 | replaceCharacter(input+1, c1, c2); 32 | } 33 | 34 | int main() { 35 | char input[1000000]; 36 | char c1, c2; 37 | cin >> input; 38 | cin >> c1 >> c2; 39 | replaceCharacter(input, c1, c2); 40 | cout << input << endl; 41 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-2/007-Remove-Duplicates-Recursive.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Remove Duplicates Recursively 7 | * - Given a string S, remove consecutive duplicates from it recursively. 8 | * 9 | * Input Format : 10 | * String S 11 | * Output Format : 12 | * Output string 13 | * 14 | * Constraints : 15 | * 1 <= |S| <= 10^3 16 | * where |S| represents the length of string 17 | * 18 | * Sample Input 1 : 19 | * aabccba 20 | * Sample Output 1 : 21 | * abcba 22 | * 23 | * Sample Input 2 : 24 | * xxxyyyzwwzzz 25 | * Sample Output 2 : 26 | * xyzwz 27 | */ 28 | void removeConsecutiveDuplicates(char *input) { 29 | if(input[0] == '\0'){ 30 | return; 31 | } 32 | removeConsecutiveDuplicates(input+1); 33 | if(input[0] == input[1]){ 34 | int i; 35 | for(i=0; input[i] != '\0'; i++){ 36 | input[i] = input[i+1]; 37 | } 38 | input[i] = '\0'; 39 | } 40 | } 41 | 42 | int main() { 43 | char s[100000]; 44 | cin >> s; 45 | removeConsecutiveDuplicates(s); 46 | cout << s << endl; 47 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-3/001-Strings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void problem1(){ 5 | string *sp = new string; 6 | *sp = "def"; 7 | cout << sp << endl; // memory address - 0x1496067f0 8 | cout << *sp << endl; // def 9 | cout<<"========================"< 2 | 3 | using namespace std; 4 | 5 | /** 6 | * All subsequences of a string 7 | */ 8 | int subsequences(string input, string output[]){ 9 | if(input.empty()){ 10 | output[0] = ""; 11 | return 1; 12 | } 13 | int smallOutputSize = subsequences(input.substr(1), output); 14 | for(int i=0; i> input; 31 | string *output = new string[1000]; 32 | int count = subsequences(input, output); 33 | for(int i=0; i 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Print Keypad Combinations Code 7 | * - Given an integer n, using phone keypad find out and print all the 8 | * possible strings that can be made using digits of input n. 9 | * - Note : The order of strings are not important. Just print different 10 | * strings in new lines. 11 | * 12 | * Input Format : 13 | * Integer n 14 | * Output Format : 15 | * All possible strings in different lines 16 | * Constraints : 17 | * 1 <= n <= 10^6 18 | * 19 | * Sample Input: 20 | * 23 21 | * Sample Output: 22 | * ad 23 | * ae 24 | * af 25 | * bd 26 | * be 27 | * bf 28 | * cd 29 | * ce 30 | * cf 31 | */ 32 | void print_keypad(int num, string output){ 33 | if(num == 0){ 34 | cout << output << endl; 35 | return; 36 | } 37 | string arr[] = {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; 38 | string str = arr[num%10]; 39 | for(int i=0; i> num; 51 | printKeypad(num); 52 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/002-recursion/code-part-3/006-StairCase.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | /** 7 | * Staircase 8 | * - A child is running up a staircase with N steps, and can hop either 9 | * 1 step, 2 steps or 3 steps at a time. Implement a method to count how 10 | * many possible ways the child can run up to the stairs. You need to 11 | * return number of possible ways W. 12 | * 13 | * Input format : 14 | * Integer N 15 | * Output Format : 16 | * Integer W 17 | * Constraints : 18 | * 1 <= N <= 30 19 | * 20 | * Sample Input 1 : 21 | * 4 22 | * Sample Output 1 : 23 | * 7 24 | * 25 | * Sample Input 2 : 26 | * 5 27 | * Sample Output 2 : 28 | * 13 29 | */ 30 | int staircase(int n){ 31 | if(n ==0 || n==1){ 32 | return 1; 33 | } 34 | if(n==2){ 35 | return 2; 36 | } 37 | int step1 = staircase(n-1); 38 | int step2 = staircase(n-2); 39 | int step3 = staircase(n-3); 40 | return step1+step2+step3; 41 | } 42 | int main() { 43 | int n, output; 44 | cin >> n; 45 | output=staircase(n); 46 | cout<< output < 2 | 3 | using namespace std; 4 | 5 | /** 6 | * What will be the Time Complexity of following code in terms of ‘n’ ? 7 | * Time - O(n) 8 | * Space - O(1) 9 | */ 10 | void problem1(){ 11 | int n, k; 12 | //Time - O(n) 13 | //Space - O(1) 14 | for(int i = 0; i < n; i++){ 15 | for(; i < n; i++){ 16 | cout << i << endl; 17 | } 18 | } 19 | //Time - O(n*k) => O(n) as K is constant 20 | for(int i = 0; i < n; i++){ 21 | for(int j = 1 ; j < k; j++){ 22 | cout << (i + j ) << endl; 23 | } 24 | } 25 | //Recurrence for merge sort 26 | // T(n) = 2T(n/2) + O(n) => O(nlogn) 27 | // S(n) = O(n) (n elements array is required at max while merge) 28 | } 29 | 30 | //Time - O(n) 31 | int multiplyRec(int m, int n){ 32 | if(n == 1) 33 | return m; 34 | return m + multiplyRec(m, n - 1); 35 | } 36 | 37 | //Time - O(logn) => log is to base 10 38 | int sumOfDigits(int n){ 39 | int sum; 40 | if(n < 10){ 41 | return n; 42 | } 43 | sum = (n % 10) + sumOfDigits(n / 10); 44 | return sum; 45 | } 46 | 47 | //Time - O(2^n) 48 | //Space - O(n) 49 | long fib(int n){ 50 | if(n == 0 || n == 1){ 51 | return n; 52 | } 53 | return fib(n - 1) + fib(n - 2); 54 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/004-test-1/README.md: -------------------------------------------------------------------------------- 1 | # Test - 1 2 | 3 | > Evaluation Time... 4 | 5 | --- 6 | 7 | ### Problems: 8 | [001 - MCQ](./code/001-MCQ.cpp)
9 | [002 - Does S Contains T](./code/002-Does-S-Contains-T.cpp)
10 | [003 - Maximum Profit on App](./code/003-Maximum-Profit-App.cpp)
11 | [004 - Split Array](./code/004-Split-Array.cpp)
12 | 13 | --- -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/004-test-1/code/001-MCQ.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * The recurrence relation capturing the optimal execution time of the 3 | * Towers of Hanoi problem with n discs is : 4 | * 1. T(n) = 2T(n − 2) + 2 5 | * 2. T(n) = 2T(n − 1) + n 6 | * 3. T(n) = 2T(n/2) + 1 7 | * 4. T(n) = 2T(n − 1) + 1 -- correct 8 | */ 9 | 10 | /** 11 | * Complexity of different operations in a sorted array. 12 | * Which of the following operations is not O(1) for an array of sorted 13 | * data. You may assume that array elements are distinct. 14 | * 1. Find the ith largest element. 15 | * 2. Delete an element -- correct 16 | * 3. Find the ith smallest element 17 | * 4. All of the above 18 | */ 19 | 20 | /** 21 | * Complexity of a Recurrence Relation 22 | * Which one of the following correctly determines the solution of the recurrence 23 | * relation with T(1) = 1? 24 | * 1. O(N) -- correct 25 | * 2. O(NlogN) 26 | * 3. O(N^2) 27 | * 4. O(logN) 28 | */ -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/005-oops/assets/OOPS-1-Classes-Members-Constructor-this.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/02-data-structure-algorithms/modules/005-oops/assets/OOPS-1-Classes-Members-Constructor-this.pdf -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/005-oops/assets/OOPS-3-Exception-Handling.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/02-data-structure-algorithms/modules/005-oops/assets/OOPS-3-Exception-Handling.pdf -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/005-oops/assets/inheritance-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/02-data-structure-algorithms/modules/005-oops/assets/inheritance-1.png -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/007-stack/README.md: -------------------------------------------------------------------------------- 1 | # Stack 2 | 3 | > ```Stack``` is a **linear data structure** which follows a particular order in which the operations are performed. The order may be ```LIFO(Last In First Out)``` or ```FILO(First In Last Out)```. 4 | 5 | > 6 | Examples : 7 | 1. plates stacked over one another in the canteen. 8 | 2. chairs stacked over one another. 9 | 10 | --- 11 | 12 | ## Problems 13 | [001 - Stack Implementation Using Arrays](./code/001-Stack-Impl-Arrays.cpp)
14 | [002 - Stack Implementation Using LinkedList](./code/002-Stack-Impl-LinkedList.cpp)
15 | [003 - Balanced Parenthesis](./code/003-Balanced-Parenthesis.cpp)
16 | [004 - Reverse a Stack](./code/004-Reverse-Stack.cpp)
17 | [005 - Check Redundant Brackets](./code/005-Check-Redundant-Brackets.cpp)
18 | [006 - Stock Span](./code/006-Stock-Span.cpp)
19 | [007 - Minimum Brackets Reversal](./code/007-Minimum-Brackets-Reversal.cpp)
20 | 21 | --- -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/008-queue/README.md: -------------------------------------------------------------------------------- 1 | # Queue 2 | 3 | > A ```Queue``` is a **linear data structure** which follows a particular order in which the operations are performed. The order is ```First In First Out (FIFO)```. 4 | 5 | > 6 | A good example of a queue is any queue of consumers for a resource where the consumer that came first is served first. 7 | 8 | > The difference between stacks and queues is in removing. In a ```stack``` we remove the item the most recently added
In a ```queue```, we remove the item the least recently added. 9 | 10 | --- 11 | 12 | ## Problems 13 | [001 - Queue Implementation Using Arrays](./code/001-Queue-Impl-Array.cpp)
14 | [002 - Queue Implementation Using LinkedList](./code/002-Queue-Impl-LinkedList.cpp)
15 | [003 - Reverse a Queue](./code/003-Reverse-Queue.cpp)
16 | 17 | --- -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/009-test-2/README.md: -------------------------------------------------------------------------------- 1 | # Test - 2 2 | 3 | > Evaluation Time... 4 | 5 | --- 6 | 7 | ### Problems: 8 | [001 - Next Number](./code/001-Next-Number.cpp)
9 | [002 - Deque](./code/002-Deque.cpp)
10 | [003 - Delete Alternate Nodes](./code/003-Delete-Alternate-Nodes.cpp)
11 | 12 | --- -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/013-test-3/README.md: -------------------------------------------------------------------------------- 1 | # Test - 3 2 | 3 | > Evaluation Time... 4 | 5 | --- 6 | 7 | ### Problems: 8 | [001 - Check Cousin](./code/001-Check-Cousin.cpp)
9 | [002 - Longest Leaf To Root Path](./code/002-Longest-Leaf-To-Root-Path.cpp)
10 | [003 - Remove Leaf Node](./code/003-Remove-Leaf-Node.cpp)
11 | 12 | --- -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/013-test-3/code/BinaryTreeNode.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | template 7 | class BinaryTreeNode { 8 | public : 9 | T data; 10 | BinaryTreeNode *left; 11 | BinaryTreeNode *right; 12 | 13 | BinaryTreeNode(T data) { 14 | this -> data = data; 15 | left = NULL; 16 | right = NULL; 17 | } 18 | }; -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/014-priority-queue/code/004-InBuilt-PQ-Usage.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | /** 18 | * Default priority queue usage present in queue.h 19 | */ 20 | int main(){ 21 | // max priority queue 22 | priority_queue pq; 23 | // min priority queue 24 | priority_queue, greater > min_pq; 25 | 26 | pq.push(16); 27 | pq.push(1); 28 | pq.push(167); 29 | pq.push(7); 30 | pq.push(45); 31 | pq.push(32); 32 | cout << "Size : " << pq.size() << endl; 33 | cout << "Top : " << pq.top() << endl; 34 | while(!pq.empty()){ 35 | cout << pq.top() << " "; 36 | pq.pop(); 37 | } 38 | cout << endl; 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/015-hashmap/code/002-Basic-Usage.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | /** 18 | * Map: 19 | * - We can store Key - Value pair in it. 20 | * - We can implement it using : 21 | * 1. BST : 22 | * map - implemented using BST - O(logn) 23 | * 2. Hashtable: 24 | * unordered_map - implemented using hashtable - O(1) 25 | */ 26 | int main(){ 27 | unordered_map mp; 28 | //insert 29 | pair p("abc", 1); 30 | mp.insert(p); 31 | mp["def"] = 2; 32 | 33 | // Find 34 | cout << mp["def"] << endl; 35 | cout << mp.at("abc") << endl; 36 | // cout << mp.at("ghi") << endl; // if not found, throw exception - key not found 37 | // cout << mp["ghi"] << endl; // if not found, insert in map - with value 0 38 | if(mp.count("ghi")){ //check presence 39 | cout << "ghi is present." << endl; 40 | } 41 | 42 | // Size 43 | cout << mp.size() << endl; 44 | 45 | // Erase element 46 | mp.erase("ghi"); 47 | } -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/015-hashmap/code/003-Remove-Duplicates.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | /** 18 | * Remove Duplicates 19 | */ 20 | vector removeDuplicates(int *arr, int n){ 21 | vector res; 22 | unordered_map mp; 23 | for(int i=0; i 0){ 25 | continue; 26 | } 27 | mp[arr[i]] = true; 28 | res.push_back(arr[i]); 29 | } 30 | return res; 31 | } 32 | 33 | int main(){ 34 | int n; 35 | cin >> n; 36 | int *arr = new int[n]; 37 | for(int i=0; i> arr[i]; 39 | } 40 | vector res = removeDuplicates(arr, n); 41 | for(int i=0; i A backtracking algorithm tries to build a solution to a computational problem incrementally. Whenever the 4 | algorithm needs to decide between multiple alternatives to the next component of the solution, it simply 5 | tries all possible options recursively. 6 | 7 | > If you have followed my project from starting - You should not have any difficulty to understand this statement. 8 | 9 | --- 10 | 11 | ### In Simple words: 12 | * It means basically - exploring all the paths possible to get the answer. 13 | * It is an approach which we can use to solve our problem and how we can implement this approach is basically , we call as recursion. 14 | 15 | --- 16 | 17 | ### Problems: 18 | [001 - N-Queens](./code/001-N-Queen.cpp)
19 | [002 - Rat In A Maze](./code/002-Rat-In-A-Maze.cpp)
20 | [003 - Crossword](./code/003-Crossword.cpp)
21 | [004 - Sudoku](./code/004-Sudoku.cpp)
22 | [005 - Subsets Sum To K](./code/005-Subsets-Sum.cpp)
23 | 24 | --- 25 | 26 | -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/020-misc-skill-tests/README.md: -------------------------------------------------------------------------------- 1 | # Skill Tests 2 | 3 | > Evaluation Time 4 | 5 | --- 6 | 7 | ## Test - CPP Group 1 8 | [002 - Donuts](./code-skill-test-1/002-Donuts.cpp)
9 | 10 | --- 11 | 12 | ## Test - CPP Group 2 13 | [001 - Power (Not yet solved)](./code-skill-test-2/001-Power.cpp)
14 | [002 - All Poosible Ways](./code-skill-test-2/002-All-Possible-Ways.cpp)
15 | [003 - Binary Play (Not yet solved)](./code-skill-test-2/003-Binary-Play.cpp)
16 | [004 - Quadreplet Sum (Not yet solved)](./code-skill-test-2/004-Quadruplet-Sum.cpp)
17 | 18 | --- 19 | 20 | ## Test - CPP Group 3 21 | [001 - In Between Linked List](./code-skill-test-3/InBetweenLinkedList_1.java)
22 | [002 - Symmetric Binary Tree](./code-skill-test-3/002-Symmetric-Binary-Tree.cpp)
23 | [003 - War On NinjaLand (Not yet solved)](./code-skill-test-3/003-War-On-NinjaLand.cpp)
24 | [004 - Find the Celebrity](./code-skill-test-3/004-Find-The-Celebrity.cpp)
25 | 26 | --- 27 | 28 | ## Test - CPP Group 4 29 | [001 - Spy Among Us](./code-skill-test-4/SpyAmongUs.java)
30 | [002 - White SubTree (Not yet solved)](./code-skill-test-4/002-White-SubTree.cpp)
31 | [003 - Jumping Ninja (Not yet solved)](./code-skill-test-4/003-Jumping-Ninja.cpp)
32 | [004 - Help Pradyumn](./code-skill-test-4/004-Help-Pradyumana.cpp)
33 | 34 | --- 35 | -------------------------------------------------------------------------------- /02-data-structure-algorithms/modules/020-misc-skill-tests/code-skill-test-1/001-Number-Star-Patter.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Number Star Pattern 3 | * - Print the following pattern for given number of rows. 4 | * 5 | * Input format : 6 | * Line 1 : N (Total number of rows) 7 | * 8 | * Sample Input : 9 | * 5 10 | * Sample Output : 11 | * 1234554321 12 | * 1234**4321 13 | * 123****321 14 | * 12******21 15 | * 1********1 16 | */ 17 | 18 | 19 | #include 20 | using namespace std; 21 | 22 | 23 | int main(){ 24 | int n; 25 | cin >> n; 26 | 27 | int row =0; 28 | while(row < n){ 29 | int num=1; 30 | for(int i=0; i 2 | #include 3 | using namespace std; 4 | int main(){ 5 | 6 | int t; 7 | cin >> t; 8 | while(t--){ 9 | int n; 10 | cin >> n; 11 | int arr[4000]; 12 | for(int i=0; i> arr[i]; 14 | } 15 | 16 | sort(arr, arr+n); 17 | 18 | int sum=0; 19 | int size=n/4; 20 | int idx = n-3; 21 | for(int i=size; i>0; i--){ 22 | sum += arr[idx]; 23 | idx -= 3; 24 | } 25 | 26 | cout << sum << endl; 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/001-prerequisite/README.md: -------------------------------------------------------------------------------- 1 | # Pre-Requisite 2 | 3 | > To proceed with **Competitive Programming** - you should be aware of basics concepts like **io**, **arrays**, **conditions**, **loops**. 4 | 5 | --- 6 | 7 | ## Problems 8 | [001 - Add Numbers - I/O from/in file](./code/001-Add-Numbers-Out-In-File.cpp)
9 | [002 - Calculate Area of 2 rectangles](./code/002-Calculate-Area-Of-Intersection.cpp)
10 | [003 - Print Array in Zig Zig format](./code/003-Print-Zig-Zag-Array.cpp)
11 | [004 - Even And Odd Indexes](./code/004-Even-And-Odd-Indexes.cpp)
12 | [005 - Total Sum Boundaries](./code/005-Total-Sum-Boundaries-Diagonals.cpp)
13 | [006 - PRE4](./code/006-PRE4.cpp)
14 | [007 - Target Marbles](./code/007-Target-Marbles.cpp)
15 | [008 - Oscillating Prices of Chakri](./code/008-Oscillating-Prices-Of-Chakri.cpp)
16 | 17 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/001-prerequisite/code/001-Add-Numbers-Out-In-File.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | freopen("../io/addin.txt", "r", stdin); 7 | freopen("../io/addout.txt", "w", stdout); 8 | 9 | int a, b; 10 | cin >> a >> b; 11 | int sum = a+b; 12 | cout << sum << endl; 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/001-prerequisite/code/002-Calculate-Area-Of-Intersection.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Calculate Area of two rectangles intersecting each other. 7 | * 8 | * Input Format : Coordinates are provided for both the rectangles 9 | * x1 y1 x2 y2 10 | * x3 y3 x4 y4 11 | * Output Format : 12 | * Area of Rectangle 13 | * 14 | * - For Example : 15 | * 1 1 3 4 16 | * 2 3 6 7 17 | * Output : 21 18 | */ 19 | 20 | int main() { 21 | freopen("../io/areain.txt", "r", stdin); 22 | freopen("../io/areaout.txt", "w", stdout); 23 | 24 | int x1, y1, x2, y2; 25 | cin >> x1 >> y1 >> x2>> y2; 26 | int x3, y3, x4 , y4; 27 | cin >> x3 >> y3 >> x4 >> y4; 28 | 29 | int area1 = (x2-x1)*(y2-y1); 30 | int area2 = (x4-x3)*(y4-y3); 31 | 32 | int left = max(x1, x3); 33 | int right = min (x2, x4); 34 | int bottom = max (y1, y3); 35 | int top = min(y2, y4); 36 | 37 | int area_intr = 0; 38 | if(left < right && bottom < top){ 39 | area_intr = (right-left) * (top-bottom); 40 | } 41 | 42 | int area = area1+area2 - area_intr; 43 | cout << area << endl; 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/001-prerequisite/io/addin.txt: -------------------------------------------------------------------------------- 1 | 2 3 -------------------------------------------------------------------------------- /03-competitive-programming/modules/001-prerequisite/io/addout.txt: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /03-competitive-programming/modules/001-prerequisite/io/areain.txt: -------------------------------------------------------------------------------- 1 | 1 1 3 4 2 | 2 3 6 7 -------------------------------------------------------------------------------- /03-competitive-programming/modules/001-prerequisite/io/areaout.txt: -------------------------------------------------------------------------------- 1 | 21 2 | -------------------------------------------------------------------------------- /03-competitive-programming/modules/001-prerequisite/io/zigzag_array_in.txt: -------------------------------------------------------------------------------- 1 | 2 4 2 | 1 1 3 4 3 | 2 3 6 7 -------------------------------------------------------------------------------- /03-competitive-programming/modules/001-prerequisite/io/zigzag_array_out.txt: -------------------------------------------------------------------------------- 1 | 1 2 3 1 3 6 7 4 -------------------------------------------------------------------------------- /03-competitive-programming/modules/002-pointers/README.md: -------------------------------------------------------------------------------- 1 | # Pointers 2 | 3 | > **Pointers** are one of the most important aspects of C++. **Pointers** are another type of veriables which store the **address** of other variables. 4 | 5 | --- 6 | 7 | ### Detailed Notes for Pointer 8 | [Click here for Pointers Notes](./assets/pointers.pdf)
9 | 10 | --- 11 | 12 | ## Problems - Code In Action 13 | 14 | [001 - Pointers](./code/001-Pointers.cpp)
15 | [002 - Pointer Arithmetic](./code/002-Pointer-Arithmetic.cpp)
16 | [003 - Arrays and Pointers](./code/003-Arrays-And-Pointers.cpp)
17 | [004 - Character Pointers](./code/004-Character-Pointers.cpp)
18 | [005 - Pointers and Functions](./code/005-Pointers-And-Functions.cpp)
19 | [006 - Double Pointers](./code/006-Double-Pointers.cpp)
20 | 21 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/002-pointers/assets/pointers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/002-pointers/assets/pointers.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/002-pointers/code/002-Pointer-Arithmetic.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * What is the output 7 | * Ans : 7 Garbage_value 8 | */ 9 | void problem1(){ 10 | int a = 7; 11 | int *c = &a; 12 | c = c + 1; 13 | cout << a << " " << *c << endl; 14 | } 15 | 16 | /** 17 | * Fill the output 18 | * - Assume memory address of variable ‘a’ is : 400 (and an integer takes 19 | * 4 bytes), what will be the output - 20 | * Ans : 412 21 | */ 22 | void problem2(){ 23 | int a = 7; 24 | int *c = &a; 25 | c = c + 3; 26 | cout << c << endl; 27 | } 28 | 29 | /** 30 | * Fill the output 31 | * - Assume memory address of variable ‘a’ is : 200 and a double variable 32 | * is of size 8 bytes, what will be the output - 33 | * Ans : 208 34 | */ 35 | void problem3(){ 36 | double a = 10.54; 37 | double *d = &a; 38 | d = d + 1; 39 | cout << d << endl; 40 | } 41 | 42 | int main() { 43 | problem1(); 44 | problem2(); 45 | problem3(); 46 | 47 | return 0; 48 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/002-pointers/code/004-Character-Pointers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | /** 5 | * Pointers Output 6 | * - What will be the output ? 7 | * Ans : b 8 | */ 9 | void problem1(){ 10 | char ch = 'a'; 11 | char* ptr = &ch; 12 | ch++; 13 | cout << *ptr << endl; 14 | } 15 | 16 | /** 17 | * What is the output 18 | * - Assume address of 0th index of array ‘b’ is 200. What is the output - 19 | * Ans : xyz 20 | */ 21 | void problem2(){ 22 | char b[] = "xyz"; 23 | char *c = &b[0]; 24 | cout << c << endl; 25 | } 26 | 27 | /** 28 | * What is the output 29 | * - Assume address of 0th index of array ‘b’ is 200. What is the output - 30 | * Ans : yz 31 | */ 32 | void problem3(){ 33 | char b[] = "xyz"; 34 | char *c = &b[0]; 35 | c++; 36 | cout << c << endl; 37 | } 38 | 39 | /** 40 | * Fill the output 41 | * Ans : h h 42 | */ 43 | void problem4(){ 44 | char s[]= "hello"; 45 | char *p = s; 46 | cout << s[0] << " " << p[0]; 47 | } 48 | 49 | int main() { 50 | problem1(); 51 | problem2(); 52 | problem3(); 53 | problem4(); 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/002-pointers/code/005-Pointers-And-Functions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Pointers Output 7 | * - Figure out the correct output of the following code. 8 | * Ans : -10 9 | */ 10 | void changeSign(int *p){ 11 | *p = (*p) * -1; 12 | } 13 | void problem1(){ 14 | int a = 10; 15 | changeSign(&a); 16 | cout << a << endl; 17 | } 18 | 19 | /** 20 | * Fill the output 21 | * Ans : 2 1 22 | */ 23 | void fun(int a[]) { 24 | cout << a[0] << " "; 25 | } 26 | void problem2() { 27 | int a[] = {1, 2, 3, 4}; 28 | fun(a + 1); 29 | cout << a[0]; 30 | } 31 | 32 | /** 33 | * Pointers Output 34 | * - What will be the output ? 35 | * Ans : 10 36 | */ 37 | void square(int *p){ 38 | int a = 10; 39 | p = &a; 40 | *p = (*p) * (*p); 41 | } 42 | void problem3(){ 43 | int a = 10; 44 | square(&a); 45 | cout << a << endl; 46 | } 47 | 48 | int main() { 49 | 50 | problem1(); 51 | problem2(); 52 | problem3(); 53 | 54 | return 0; 55 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/002-pointers/code/006-Double-Pointers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * What will be the output ? 7 | * Ans : 10 21 8 | */ 9 | void problem1(){ 10 | int a = 10; 11 | int *p = &a; 12 | int **q = &p; 13 | int b = 20; 14 | *q = &b; 15 | (*p)++; 16 | cout << a << " " << b << endl; 17 | } 18 | 19 | /** 20 | * What will be the output ? 21 | * Ans : 101 104 22 | */ 23 | void problem2(){ 24 | int a = 100; 25 | int *p = &a; 26 | int **q = &p; 27 | int b = (**q)++ + 4; 28 | cout << a << " " << b << endl; 29 | } 30 | 31 | /** 32 | * Pointers Output 33 | * - What will be the output ? 34 | * Ans : 102 100 35 | */ 36 | void problem3(){ 37 | int a = 100; 38 | int *p = &a; 39 | int **q = &p; 40 | int b = (**q)++; 41 | int *r = *q; 42 | (*r)++; 43 | cout << a << " " << b << endl; 44 | } 45 | 46 | /** 47 | * Pointers Output 48 | * - What will be the output ? 49 | * Ans : 11 50 | */ 51 | void increment(int **p){ 52 | (**p)++; 53 | } 54 | void problem4(){ 55 | int num = 10; 56 | int *ptr = # 57 | increment(&ptr); 58 | cout << num << endl; 59 | } 60 | 61 | int main() { 62 | problem1(); 63 | problem2(); 64 | problem3(); 65 | problem4(); 66 | 67 | return 0; 68 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/003-dynamic-allocation/README.md: -------------------------------------------------------------------------------- 1 | # Dynamic Allocation 2 | 3 | > **Dynamic Allocation** mainly refers to the allocation of memory at run time in the **Heap**. 4 | 5 | --- 6 | 7 | ## Problems 8 | 9 | [001 - Address Typecasting](./code/001-Address-Typecasting.cpp)
10 | [002 - Pass by Reference](./code/002-Pass-By-Reference.cpp)
11 | [003 - Dynamic Memory allocation](./code/003-Dynamic-Memory-Allocation.cpp)
12 | [004 - Macros and Global Variables](./code/004-Macros-Global-Vars.cpp)
13 | [005 - Inline Function and Default Arguments](./code/005-Inline-Default-Arguments.cpp)
14 | [006 - Constant Variables](./code/006-Constant-Vars.cpp)
15 | 16 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/003-dynamic-allocation/code/001-Address-Typecasting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void basics(){ 6 | int i=65; 7 | char c = i; // implicit typecasting 8 | cout << c << endl; 9 | 10 | int *p = &i; 11 | char *pc = (char*)p; //explicit typecastings 12 | 13 | cout << *p << endl; // 65 14 | cout << *pc << endl; // A - integer is stored in reverse order i.e. least significant bytes 15 | cout << *(pc+1) << endl; // nullpoiinter 16 | cout << *(pc+2) << endl; // nullpoiinter 17 | cout << *(pc+3) << endl; // nullpoiinter 18 | } 19 | 20 | /** 21 | * Void pointer can be of which type : 22 | * 1. int 23 | * 2. double 24 | * 3. float 25 | * 4. all 26 | * Ans : 4(all) 27 | */ 28 | 29 | /** 30 | * What is the output 31 | * Ans : A 32 | */ 33 | void problem1(){ 34 | int d = 65; 35 | int i = d; 36 | char ch = i; 37 | cout << ch << endl; 38 | } 39 | 40 | /** 41 | * What is the output 42 | * Ans : d 43 | */ 44 | void updateValue(int *p){ 45 | *p = 610 % 255; 46 | } 47 | void problem2(){ 48 | char ch = 'A'; 49 | updateValue((int*)&ch); 50 | cout << ch; 51 | } 52 | 53 | int main() { 54 | 55 | basics(); 56 | problem1(); 57 | problem2(); 58 | 59 | return 0; 60 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/003-dynamic-allocation/code/002-Pass-By-Reference.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void increment(int &i){ 6 | i++; 7 | } 8 | void basics(){ 9 | int i=10; 10 | int &j = i; // reference variable 11 | 12 | i++; 13 | cout << j << endl; 14 | 15 | increment(i); // pass by reference 16 | cout << i << endl; 17 | } 18 | 19 | /** 20 | * What is the output 21 | * Ans : 10 11 22 | */ 23 | void func(int p){ 24 | cout << p << " "; 25 | } 26 | void problem1(){ 27 | int i = 10; 28 | int &p = i; 29 | func(p++); 30 | cout << i; 31 | } 32 | 33 | /** 34 | * What is the output 35 | * Ans : 10 7 10 36 | */ 37 | void func(int i, int& j, int p){ 38 | i++; 39 | j++; 40 | p++; 41 | } 42 | void problem2(){ 43 | int i = 10; 44 | int j = 6; 45 | int &p = i; 46 | func(i, j, p); 47 | cout << i << " " << j << " " << p; 48 | } 49 | 50 | int main() { 51 | basics(); 52 | problem1(); 53 | problem2(); 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/004-recursion/assets/recursion.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/004-recursion/assets/recursion.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/004-recursion/code/001-Factorial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int factorial(int n){ 6 | if(n == 0){ 7 | return 1; 8 | } 9 | int ans = factorial(n-1); 10 | return n * ans; 11 | } 12 | 13 | int main() { 14 | int n; 15 | cin >> n; 16 | int output = factorial(n); 17 | cout << output << endl; 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/004-recursion/code/002-Power.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Power 7 | * - Write a program to find x to the power n (i.e. x^n). Take x and n 8 | * from the user. You need to return the answer. 9 | * - Do this recursively. 10 | * Input format : 11 | * Two integers x and n (separated by space) 12 | * Output Format : 13 | * x^n (i.e. x raise to the power n) 14 | * 15 | * Constraints : 16 | * 1 <= x <= 30 17 | * 0 <= n <= 30 18 | * 19 | * Sample Input 1 : 20 | * 3 4 21 | * Sample Output 1 : 22 | * 81 23 | * 24 | * Sample Input 2 : 25 | * 2 5 26 | * Sample Output 2 : 27 | * 32 28 | */ 29 | 30 | int power(int x, int n){ 31 | if(n==0){ 32 | return 1; 33 | } 34 | int ans = power(x, n-1); 35 | return x * ans; 36 | } 37 | 38 | int main(){ 39 | int x, n; 40 | cin >> x >> n; 41 | 42 | cout << power(x, n) << endl; 43 | } 44 | -------------------------------------------------------------------------------- /03-competitive-programming/modules/004-recursion/code/003-Print-Numbers.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Print Numbers 7 | * - Given is the code to print numbers from 1 to n in increasing 8 | * order recursively. 9 | * Input Format : 10 | * Integer n 11 | * Output Format : 12 | * Numbers from 1 to n (separated by space) 13 | * Constraints : 14 | * 1 <= n <= 10000 15 | * 16 | * Sample Input 1 : 17 | * 6 18 | * Sample Output 1 : 19 | * 1 2 3 4 5 6 20 | * 21 | * Sample Input 2 : 22 | * 4 23 | * Sample Output 2 : 24 | * 1 2 3 4 25 | */ 26 | void print(int n){ 27 | if(n == 1){ 28 | cout << n << " "; 29 | return; 30 | } 31 | print(n - 1); 32 | cout << n << " "; 33 | } 34 | 35 | int main(){ 36 | int n; 37 | cin >> n; 38 | 39 | print(n); 40 | } 41 | -------------------------------------------------------------------------------- /03-competitive-programming/modules/004-recursion/code/004-Number-Of-Digits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Number of Digits 7 | * - Given the code to find out and return the number of digits present 8 | * in a number recursively. 9 | * 10 | * Input Format : 11 | * Integer n 12 | * Output Format : 13 | * Count of digits 14 | * Constraints : 15 | * 1 <= n <= 10^6 16 | * 17 | * Sample Input 1 : 18 | * 156 19 | * Sample Output 1 : 20 | * 3 21 | * 22 | * Sample Input 2 : 23 | * 7 24 | * Sample Output 2 : 25 | * 1 26 | */ 27 | int count(int n){ 28 | if(n <= 9){ 29 | return 1; 30 | } 31 | int smallAns = count(n / 10); 32 | return smallAns + 1; 33 | } 34 | 35 | int main(){ 36 | int n; 37 | cin >> n; 38 | 39 | cout << count(n) << endl; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /03-competitive-programming/modules/004-recursion/code/005-Fibonicci.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Fibonicci Series : 7 | * Fib(n) = Fib(n-1) + Fib(n-2) 8 | * 9 | */ 10 | int fib(int n){ 11 | if(n==0){ 12 | return 0; 13 | } 14 | if(n==1){ 15 | return 1; 16 | } 17 | int ans1 = fib(n-1); 18 | int ans2 = fib(n-2); 19 | return ans1 + ans2; 20 | } 21 | 22 | int main() { 23 | int n; 24 | cin >> n; 25 | cout << fib(n) << endl; 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/004-recursion/code/007-Check-If-Array-Sorted.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Check if the array is sorted or not. 7 | */ 8 | 9 | bool isSorted(int* arr, int n){ 10 | if(n == 0 || n == 1){ 11 | return true; 12 | } 13 | if(arr[0] > arr[1]){ 14 | return false; 15 | } 16 | return isSorted(arr+1, n-1); 17 | } 18 | 19 | int main() { 20 | int n; 21 | cin >> n; 22 | int *arr = new int[n]; 23 | for(int i=0; i> arr[i]; 25 | } 26 | isSorted(arr, n) ? cout << "true" : cout << "false"; 27 | 28 | delete [] arr; 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/004-recursion/code/008-Sum-Of-Array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Sum of Array 7 | * - Given an array of length N, you need to find and return the sum of 8 | * all elements of the array. 9 | * - Do this recursively. 10 | * Input Format : 11 | * Line 1 : An Integer N i.e. size of array 12 | * Line 2 : N integers which are elements of the array, separated by spaces 13 | * Output Format : 14 | * Sum 15 | * Constraints : 16 | * 1 <= N <= 10^3 17 | * 18 | * Sample Input 1 : 19 | * 3 20 | * 9 8 9 21 | * Sample Output 1 : 22 | * 26 23 | * 24 | * Sample Input 2 : 25 | * 3 26 | * 4 2 1 27 | * Sample Output 2 : 28 | * 7 29 | */ 30 | int sum(int input[], int n) { 31 | if(n == 0){ 32 | return 0; 33 | } 34 | int ans = sum(input+1, n-1); 35 | return input[0] + ans; 36 | } 37 | 38 | 39 | int main(){ 40 | int n; 41 | cin >> n; 42 | int *input = new int[n]; 43 | for(int i = 0; i < n; i++) { 44 | cin >> input[i]; 45 | } 46 | cout << sum(input, n) << endl; 47 | delete [] input; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /03-competitive-programming/modules/005-Complexity-And-Language-Tools/assets/CP-Notes-Language-Tools.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/005-Complexity-And-Language-Tools/assets/CP-Notes-Language-Tools.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/005-Complexity-And-Language-Tools/assets/Language-Tools-C++.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/005-Complexity-And-Language-Tools/assets/Language-Tools-C++.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/005-Complexity-And-Language-Tools/assets/Language-Tools-Java.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/005-Complexity-And-Language-Tools/assets/Language-Tools-Java.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/005-Complexity-And-Language-Tools/assets/Language-Tools-Python.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/005-Complexity-And-Language-Tools/assets/Language-Tools-Python.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/005-Complexity-And-Language-Tools/assets/Time-Space-Complexity.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/005-Complexity-And-Language-Tools/assets/Time-Space-Complexity.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/005-Complexity-And-Language-Tools/code-part-3/005-Sum-Me-Up.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Sum me Up 7 | * - There will be ‘t’ test cases having an integer. You have to sum up 8 | * all the digits of this integer. For e.g. For 6754, the answer will 9 | * be 6 + 7 + 5 + 4 = 22. 10 | * Input Format: 11 | * First line will have an integer ‘t’ denoting the number of test cases. 12 | * Next ‘t’ lines will have an integer ‘val’ each. 13 | * Output format: 14 | * Print ‘t’ lines of output denoting the sum of all the digits of the 15 | * number in each test case. 16 | * 17 | * Constraints: 18 | * 1 <= t <= 10^5 19 | * 0 <= val <= 10^18 20 | * 21 | * Sample Input: 22 | * 2 23 | * 1547 24 | * 45876 25 | * Sample Output: 26 | * 17 27 | * 30 28 | * Explanation: 29 | * 1 + 5 + 4 + 7 = 17 30 | * 4 + 5 + 8 + 7 + 6 = 30 31 | */ 32 | 33 | typedef long long int ll; 34 | 35 | int sumDigits(ll num){ 36 | int ans = 0; 37 | while(num){ 38 | ans += num%10; 39 | num = num/10; 40 | } 41 | return ans; 42 | } 43 | 44 | int main() { 45 | 46 | int t; 47 | cin >> t ; 48 | 49 | while(t--){ 50 | ll num; 51 | cin >> num; 52 | cout << sumDigits(num) << endl; 53 | } 54 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/006-searching-sorting/README.md: -------------------------------------------------------------------------------- 1 | # Searching & Sorting 2 | 3 | > **Searching** : finding out if element is present in the given array/list. 4 | 5 | > **Sorting** : It refers to the arrangement of elements in an ordered sequence either in increasing or decreasing order. 6 | 7 | --- 8 | 9 | ## Notes 10 | 11 | [Click here for Searching and Sorting](./assets/Searching-And-Sorting-Applications.pdf)
12 | 13 | --- 14 | 15 | ### Problems 16 | 17 | [001 - Agressive Cows](./code/001-Aggressive-Cows.cpp)
18 | [002 - Inversion Count](./code/002-Inversion-Count.cpp)
19 | [003 - Chef Restaurant](./code/003-Chef-Restaurant.cpp)
20 | [004 - Variation Pairs](./code/004-Variation-Pairs.cpp)
21 | [005 - Murder](./code/005-Murder.cpp)
22 | [006 - Distribute Candies](./code/006-Distribute-Candies.cpp)
23 | [007 - Momos Market](./code/007-Momos-Market.cpp)
24 | [008 - Taj Mahal Entry](./code/008-Taj-Mahal-Entry.cpp)
25 | 26 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/006-searching-sorting/assets/Searching-And-Sorting-Applications.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/006-searching-sorting/assets/Searching-And-Sorting-Applications.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/007-Advance-Recursion/assets/Advanced-Recursion.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/007-Advance-Recursion/assets/Advanced-Recursion.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/007-Advance-Recursion/code/001-Length.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int length(char str[]){ 6 | if(str[0] == '\0'){ 7 | return 0; 8 | } 9 | int ans = length(str+1); 10 | return 1+ans; 11 | } 12 | 13 | int main() { 14 | char str[100]; 15 | cin >> str; 16 | 17 | int l = length(str); 18 | cout << l << endl; 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/007-Advance-Recursion/code/002-Replace-Character-Recursive.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Replace Character Recursively 7 | * - Given an input string S and two characters c1 and c2, you need to 8 | * replace every occurrence of character c1 with character c2 in the 9 | * given string. 10 | * - Do this recursively. 11 | * 12 | * Input Format : 13 | * Line 1 : Input String S 14 | * Line 2 : Character c1 and c2 (separated by space) 15 | * Output Format : 16 | * Updated string 17 | * Constraints : 18 | * 1 <= Length of String S <= 10^6 19 | * 20 | * Sample Input : 21 | * abacd 22 | * a x 23 | * Sample Output : 24 | * xbxcd 25 | */ 26 | 27 | void replaceCharacter(char input[], char c1, char c2) { 28 | if(input[0] == '\0'){ 29 | return; 30 | } 31 | if(input[0] == c1){ 32 | input[0] = c2; 33 | } 34 | replaceCharacter(input+1, c1, c2); 35 | } 36 | 37 | int main() { 38 | char input[1000000]; 39 | char c1, c2; 40 | cin >> input; 41 | cin >> c1 >> c2; 42 | replaceCharacter(input, c1, c2); 43 | cout << input << endl; 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/007-Advance-Recursion/code/003-Remove-Duplicates-Recursive.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Remove Duplicates Recursively 7 | * - Given a string S, remove consecutive duplicates from it recursively. 8 | * 9 | * Input Format : 10 | * String S 11 | * Output Format : 12 | * Output string 13 | * Constraints : 14 | * 1 <= |S| <= 10^3 15 | * where |S| represents the length of string 16 | * 17 | * Sample Input 1 : 18 | * aabccba 19 | * Sample Output 1 : 20 | * abcba 21 | * 22 | * Sample Input 2 : 23 | * xxxyyyzwwzzz 24 | * Sample Output 2 : 25 | * xyzwz 26 | */ 27 | 28 | void removeConsecutiveDuplicates(char *input) { 29 | if(input[0] == '\0'){ 30 | return ; 31 | } 32 | removeConsecutiveDuplicates(input+1); 33 | if(input[0] == input[1]){ 34 | int i; 35 | for(i=0; input[i] != '\0'; i++){ 36 | input[i] = input[i+1]; 37 | } 38 | input[i] = '\0'; 39 | } 40 | } 41 | 42 | int main() { 43 | char s[100000]; 44 | cin >> s; 45 | removeConsecutiveDuplicates(s); 46 | cout << s << endl; 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/007-Advance-Recursion/code/006-Return-Subsequences.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Return SubSequences of String 7 | * 8 | * Sample Input1: 9 | * abc 10 | * Sample Output1: 11 | * 12 | * a 13 | * b 14 | * c 15 | * ab 16 | * bc 17 | * ac 18 | * abc 19 | */ 20 | 21 | int subsequences(string input, string* output){ 22 | if(input.empty()){ 23 | output[0] = ""; 24 | return 1; 25 | } 26 | int size = subsequences(input.substr(1), output); 27 | for(int i=0; i> str; 36 | 37 | string* output = new string[10000]; 38 | int size = subsequences(str, output); 39 | for(int i=0; i 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Print all the subsequences of String 7 | * 8 | * Sample Input1: 9 | * abc 10 | * Sample Output1: 11 | * 12 | * a 13 | * b 14 | * c 15 | * ab 16 | * bc 17 | * ac 18 | * abc 19 | */ 20 | 21 | void printSubsequences(string input, string output){ 22 | if(input.empty()){ 23 | cout << output << endl; 24 | return; 25 | } 26 | printSubsequences(input.substr(1), output); 27 | printSubsequences(input.substr(1), output + input[0]); 28 | } 29 | 30 | int main() { 31 | string str; 32 | cin >> str; 33 | 34 | string out; 35 | printSubsequences(str, out); 36 | 37 | return 0; 38 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/008-Backtracking/README.md: -------------------------------------------------------------------------------- 1 | # BackTracking 2 | 3 | > ```BackTracking``` refers to traversing all the possible paths to reach to the destination. 4 | 5 | --- 6 | 7 | ## Notes 8 | 9 | [Click here for Backtracking](./assets/Backtracking.pdf)
10 | 11 | --- 12 | 13 | ## Problems - Backtracking 14 | 15 | [001 - nQueens](./code-part-1/001-nQueens.cpp)
16 | [002 - Rat In A Maze](./code-part-1/002-RatInAMaze.cpp)
17 | [003 - Crossword](./code-part-1/003-Crossword.cpp)
18 | 19 | --- 20 | 21 | ## Problems - Backtracking, Binary Search & Merge Sort Problems 22 | 23 | [001 - Find Power of Number](./code-part-2/001-Find-Power.cpp)
24 | [002 - Sorting the skills](./code-part-2/002-Sorting-Skills.cpp)
25 | [003 - Collecting the balls](./code-part-2/003-Collecting-Balls.cpp)
26 | [004 - Sudoku Solver](./code-part-2/004-Sudoku-Solver.cpp)
27 | 28 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/008-Backtracking/assets/Backtracking.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/008-Backtracking/assets/Backtracking.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/008-Backtracking/code-part-2/001-Find-Power.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Find power of a number 7 | * - Write a program to find x to the power n (i.e. x^n). Take x and n from 8 | * the user. You need to print the answer. 9 | * Note : For this question, you can assume that 0 raised to the power of 0 is 1 10 | * 11 | * Input format : 12 | * Two integers x and n (separated by space) 13 | * Output Format : 14 | * x^n (i.e. x raise to the power n) 15 | * Constraints: 16 | * 0 <= x <= 8 17 | * 0 <= n <= 9 18 | * 19 | * Sample Input 1 : 20 | * 3 4 21 | * Sample Output 1 : 22 | * 81 23 | * 24 | * Sample Input 2 : 25 | * 2 5 26 | * Sample Output 2 : 27 | * 32 28 | */ 29 | 30 | int power(int x, int n){ 31 | if(n == 0){ 32 | return 1; 33 | } 34 | return x*power(x, n-1); 35 | } 36 | 37 | int main() { 38 | 39 | int x, n; 40 | cin >> x >> n; 41 | 42 | int ans = power(x, n); 43 | cout << ans << endl; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /03-competitive-programming/modules/009-Bit-Manipulation/README.md: -------------------------------------------------------------------------------- 1 | # Bit Manipulation 2 | 3 | > Sometimes, we can use **Bitwise Operators** to solve any problem so reduce the time complexity by fractions.
4 | Ex. If we have to check whether the number is even or odd , we can use **&** operator. 5 | 6 | --- 7 | 8 | ## Notes 9 | 10 | [Click here for Bit Manipulation](./assets/Bit-Manipulation.pdf)
11 | 12 | --- 13 | 14 | ## Problems 15 | 16 | [001 - Bitwise Operators](./code/001-Bitwise-Operators.cpp)
17 | [002 - Set ith bit](./code/002-Set-ith-Bit.cpp)
18 | [003 - Unset ith bit](./code/003-Unset-ith-Bit.cpp)
19 | [004 - Flip the ith bit](./code/004-Flip-the-ith-Bit.cpp)
20 | [005 - Check if Number is Even or Odd](./code/005-Check-If-Number-Even-Odd.cpp)
21 | [006 - Check Power of Two](./code/006-Check-Power-Of-Two.cpp)
22 | [007 - Find First Set bit](./code/007-Find-First-Set-Bit.cpp)
23 | [008 - Turn off the First bit](./code/008-Turn-Off-The-First-Bit.cpp)
24 | [009 - Clear All Bits from LSB](./code/009-Clear-All-Bit-From-LSB.cpp)
25 | [010 - Clear All Bits from MSB](./code/010-Clear-All-Bits-From-MSB.cpp)
26 | 27 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/009-Bit-Manipulation/assets/Bit-Manipulation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/009-Bit-Manipulation/assets/Bit-Manipulation.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/009-Bit-Manipulation/code/002-Set-ith-Bit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Set ith bit 7 | * - You are given two integers N and i. You need to make ith bit of binary 8 | * representation of N to 1 and return the updated N. 9 | * - Counting of bits start from 0 from right to left. 10 | * 11 | * Input Format : 12 | * Two integers N and i (separated by space) 13 | * Output Format : 14 | * Updated N 15 | * 16 | * Sample Input 1 : 17 | * 4 1 18 | * Sample Output 1 : 19 | * 6 20 | * 21 | * Sample Input 2 : 22 | * 4 4 23 | * Sample Output 2 : 24 | * 20 25 | */ 26 | 27 | int turnOnIthBit(int n, int i){ 28 | return (n | (1 << i)); 29 | } 30 | 31 | int main() { 32 | int n, i; 33 | cin >> n >> i; 34 | cout<< turnOnIthBit(n, i) < 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Unset ith bit 7 | * - You are given two integers N and i. You need to make ith bit of 8 | * binary representation of N to 0 and return the updated N. 9 | * - Counting of bits start from 0 from right to left. 10 | * 11 | * Input Format : 12 | * Two integers N and i (separated by space) 13 | * Output Format : 14 | * Updated N 15 | * 16 | * Sample Input 1 : 17 | * 7 2 18 | * Sample Output 1 : 19 | * 3 20 | * 21 | * Sample Input 2 : 22 | * 12 1 23 | * Sample Output 2 : 24 | * 12 25 | */ 26 | 27 | int turnOffIthBit(int n, int i){ 28 | return n & (~(1<> n >> i; 34 | cout<< turnOffIthBit(n, i) < 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Flip the ith bit of a Number. 7 | * 8 | * Sample Input : 9 | * 11 2 10 | * Sample Output : 11 | * 15 12 | */ 13 | 14 | int flip(int n , int i){ 15 | return n ^ (1 << i); 16 | } 17 | 18 | int main() { 19 | int n, i; 20 | cin >> n >> i; 21 | int ans = flip(n, i); 22 | cout << ans << endl; 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/009-Bit-Manipulation/code/005-Check-If-Number-Even-Odd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Check if number is is odd or even . 7 | * 8 | * Sample Input: 9 | * 556 10 | * Sample Output: 11 | * even 12 | */ 13 | 14 | void checkEven(int num){ 15 | if(num & 1){ 16 | cout << "odd" << endl; 17 | return; 18 | } 19 | cout << "even" << endl; 20 | } 21 | 22 | int main() { 23 | int n; 24 | cin >> n; 25 | checkEven(n); 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/009-Bit-Manipulation/code/006-Check-Power-Of-Two.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Check if the given number is power of two. 7 | * 8 | * Sample Input: 9 | * 8 10 | * Sample Output: 11 | * true 12 | */ 13 | 14 | void checkPowerOfTwo(int n){ 15 | if((n & (n-1)) == 0){ 16 | cout << "true" << endl; 17 | return; 18 | } 19 | cout << "false" << endl; 20 | } 21 | 22 | int main() { 23 | int n; 24 | cin >> n; 25 | checkPowerOfTwo(n); 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/009-Bit-Manipulation/code/007-Find-First-Set-Bit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Find first set bit 7 | * - You are given an integer N. You need to return an integer M, in which 8 | * only one bit is set which at position of lowest set bit of N (from 9 | * right to left). 10 | * Input Format : 11 | * Integer N 12 | * Output Format : 13 | * Integer M 14 | * 15 | * Sample Input 1 : 16 | * 7 17 | * Sample Output 1 : 18 | * 1 19 | * 20 | * Sample Input 2 : 21 | * 12 22 | * Sample Output 2 : 23 | * 4 24 | */ 25 | int returnFirstSetBit(int n){ 26 | return n - (n & n - 1); 27 | } 28 | 29 | int main() { 30 | int n; 31 | cin >> n; 32 | cout<< returnFirstSetBit(n) < 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Turn off 1st set bit 7 | * - You are given an integer Ni. You need to make first set bit of 8 | * binary representation of N to 0 and return the updated N. 9 | * - Counting of bits start from 0 from right to left. 10 | * 11 | * Input Format : 12 | * Integer N 13 | * Output Format : 14 | * Updated N 15 | * 16 | * Sample Input 1 : 17 | * 4 18 | * Sample Output 1 : 19 | * 0 20 | * 21 | * Sample Input 2 : 22 | * 12 23 | * Sample Output 2 : 24 | * 8 25 | */ 26 | 27 | int turnOffFirstSetBit(int n){ 28 | int firstBitNum = (n - (n & n-1)); 29 | return n - firstBitNum; 30 | } 31 | 32 | int main() { 33 | int n; 34 | cin >> n; 35 | cout<< turnOffFirstSetBit(n) < 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Clear All Bits From LSB 7 | * - You are given two integers N and i. You need to clear all bits from LSB 8 | * to ith bit (start i from right to left) and return the updated N. 9 | * - Counting of bits starts from 0 from right to left. 10 | * 11 | * Input Format : 12 | * Two integers N and i (separated by space) 13 | * Output Format : 14 | * Updated N 15 | * 16 | * Sample Input 1 : 17 | * 15 1 18 | * Sample Output 1 : 19 | * 12 20 | */ 21 | 22 | int clearAllBits(int n, int i){ 23 | int mask = ~((1 << (i+1))-1); 24 | return n & mask; 25 | } 26 | 27 | int main() { 28 | int n, i; 29 | cin >> n >> i; 30 | cout<< clearAllBits(n, i) < 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Clear All Bits From MSB 7 | * - You are given two integers N and i. You need to clear all bits from MSB 8 | * to ith bit (start i from right to left) and return the updated N. 9 | * - Counting of bits starts from 0 from right to left. 10 | * 11 | * Input Format : 12 | * Two integers N and i (separated by space) 13 | * Output Format : 14 | * Updated N 15 | * 16 | * Sample Input 1 : 17 | * 15 2 18 | * Sample Output 1 : 19 | * 3 20 | * Sample Output 1 Explanation : 21 | * We need to clear all bits from MSB to ith bit i.e. clear all bits except 22 | * 0th and 1st. 23 | * 24 | * Sample Input 2 : 25 | * 4 4 26 | * Sample Output 2 : 27 | * 4 28 | */ 29 | 30 | int clearAllBits(int n, int i){ 31 | int mask = (1 << i) - 1; 32 | return n & mask; 33 | } 34 | 35 | int main() { 36 | int n, i; 37 | cin >> n >> i; 38 | cout<< clearAllBits(n, i) < 6 | 7 | --- 8 | 9 | ## Problems 10 | 11 | [001 - Equalize](./code/001-Equalize.cpp)
12 | [002 - Rectangular Area](./code/002-Rectangular-Area.cpp)
13 | [003 - Light Up the Bulb](./code/003-Light-Up-The-Bulb.cpp)
14 | [004 - Circular List of Students](./code/004-Circular-List-Of-Students.cpp)
15 | [005 - Interesting Sequence](./code/005-Interesting-Sequence.cpp)
16 | [006 - Winning Strategy](./code/006-Winning-Strategy.cpp)
17 | 18 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/010-Adhoc-Problems/assets/Adhoc-Problems.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/010-Adhoc-Problems/assets/Adhoc-Problems.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/011-Modulo-Arithmetic/README.md: -------------------------------------------------------------------------------- 1 | # Modulo Arithmetic (%) 2 | 3 | > In short, **Modulo Operator(%)** is used in **CP** when we are having the answers going out of range from **datatype limit**. 4 | 5 | > Generally, in questions, ask is to convert the answer to **10^9 + 7**.

Reason to choose this number:
6 | 1. Number is very large like 2^100.
7 | 2. Number is prime - 10^9+7. 8 | 9 | --- 10 | 11 | ## Notes 12 | 13 | [Click here for Modulo Arithmetic](./assets/Modulo-Arithmetic.pdf)
14 | 15 | --- 16 | 17 | 18 | ### Modulo Properties 19 | 20 | 1. (a+b) % c => ((a%c) + (b%c)) % c 21 | 2. (a*b) % c => ((a%c) * (b%c)) % c 22 | 3. (a-b) % c => ((a%c) - (b%c)) % c 23 | 4. (a/b) % c => ((a%c) / (b%c)) % c 24 | 25 | --- 26 | 27 | ### Modulo Operation 28 | - Answer with modulo should be in the range - **(0 to n-1)** 29 | - If our ans is coming as negative then the formulae is changed a bit :
30 | - Example : -5 % 3 = -2
31 | So, formulae will be changed in this case : **(a%m + m) % m**
32 | i.e ((-5 % 3) + 3 ) % 3 = 1 33 | 34 | --- 35 | 36 | ## Problems 37 | 38 | [001 - Number of Balanced Trees](./code/001-Number-Of-Balanced-Trees.cpp)
39 | 40 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/011-Modulo-Arithmetic/assets/Modulo-Arithmetic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/011-Modulo-Arithmetic/assets/Modulo-Arithmetic.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/012-Dynamic-Programming/assets/Dynamic-Programming-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/012-Dynamic-Programming/assets/Dynamic-Programming-1.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/012-Dynamic-Programming/assets/Dynamic-Programming-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/012-Dynamic-Programming/assets/Dynamic-Programming-2.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/012-Dynamic-Programming/code-part-1/001-Fibonicci.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Fibonicci Series 7 | */ 8 | 9 | // Approach 1 - Brute Force - O(2^n) 10 | int fib(int n){ 11 | if(n ==0 || n == 1){ 12 | return 1; 13 | } 14 | return fib(n-1) + fib(n-2); 15 | } 16 | 17 | // Approach 2 - Memoization - O(n) 18 | int fib(int n, int* arr){ 19 | if(n==0 || n==1){ 20 | return 1; 21 | } 22 | if(arr[n] > 0){ 23 | return arr[n]; 24 | } 25 | int output = fib(n-1, arr) + fib(n-2, arr); 26 | arr[n] = output; 27 | return output; 28 | } 29 | 30 | // Approach 3 - DP - O(n) 31 | int fib_dp(int n){ 32 | int *arr = new int[n+1]; 33 | arr[0] = 1; 34 | arr[1] = 1; 35 | for(int i=2; i> n; 46 | int* arr = new int[n]; 47 | for(int i=0; i 7 | 8 | --- 9 | 10 | ### Problems 11 | 12 | [001 - Minimum Absolute Difference in an Array](./code/001-Min-Absolute-Diff-In-An-Array.cpp)
13 | [002 - Nikunj and Donuts](./code/002-Nikunj-And-Donuts.cpp)
14 | [003 - Activity Selection](./code/003-Activity-Selection.cpp)
15 | [004 - Fractional Knapsack](./code/004-Fractional-Knapsack.cpp)
16 | [005 - Weighted Job Scheduling](./code/005-Weighted-Job-Scheduling.cpp)
17 | 18 | --- 19 | 20 | ### Assignment 21 | 22 | [001 - Perimeter with Conditions](./code/006-Perimeter-With-Conditions.cpp)
23 | [002 - Problem Discussion](./code/007-Problem-Discussion.cpp)
24 | [003 - Winning Lottery](./code/008-Winning-Lottery.cpp)
25 | 26 | -------------------------------------------------------------------------------- /03-competitive-programming/modules/013-Greedy-Problems/assets/Greedy-Problems.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/013-Greedy-Problems/assets/Greedy-Problems.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/014-Segment-Trees/README.md: -------------------------------------------------------------------------------- 1 | # Segment Trees 2 | 3 | 4 | ## Notes 5 | 6 | [Click here for Segment Trees](./assets/Segment-Trees.pdf)
7 | 8 | --- 9 | 10 | ### Problems 11 | 12 | [001 - Segment Tree Basic Operations](./code/001-Segment-Tree-Operations.cpp)
13 | [002 - Minimum in Subarray](./code/002-Minimum-In-Subarray.cpp)
14 | [003 - Maximum Pair Sum](./code/003-Maximum-Pair-Sum.cpp)
15 | [004 - Maximum Sum in Subarray](./code/004-Maximum-Sum-In-Subarray.cpp)
16 | [005 - Lazy Propagation](./code/005-Lazy-Propagation.cpp)
17 | [006 - Sum of Squares](./code/006-Sum-Of-Squares.cpp)
18 | 19 | --- 20 | 21 | ### Assignment 22 | 23 | [001 - Counting Even Odd](./code/007-Counting-Even-Odd.cpp)
24 | [002 - Vasya vs Rhezo](./code/008-Vasya-vs-Rhezo.cpp)
25 | [003 - 2 vs 3](./code/009-2-vs-3.cpp)
26 | [004 - Horrible Queries](./code/010-Horrible-Queries.cpp)
27 | 28 | -------------------------------------------------------------------------------- /03-competitive-programming/modules/014-Segment-Trees/assets/Segment-Trees.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/014-Segment-Trees/assets/Segment-Trees.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/015-Graphs/assets/Advance-Graphs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/015-Graphs/assets/Advance-Graphs.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/015-Graphs/assets/Graphs-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/015-Graphs/assets/Graphs-1.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/015-Graphs/assets/Graphs-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/015-Graphs/assets/Graphs-2.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/016-String-Algorithms/README.md: -------------------------------------------------------------------------------- 1 | # String Algorithms 2 | 3 | 4 | ## Notes 5 | 6 | [Click here for String Algorithms](./assets/String-Algorithms.pdf)
7 | 8 | --- 9 | 10 | ### Problems 11 | 12 | [001 - Pattern Matching - Naive Approach](./code/001-Pattern-Matching-Naive.cpp)
13 | [002 - Longest Prefix Suffix](./code/002-Longest-Prefix-Suffix.cpp)
14 | [003 - KMP Algorithm](./code/003-KMP-Algorithm.cpp)
15 | [004 - String Search](./code/004-String-Search.cpp)
16 | [005 - Z Algorithm](./code/005-Z-Algorithm.cpp)
17 | [006 - Longest Palindromic Substring](./code/006-Longest-Palindromic-Substring.cpp)
18 | [007 - Palindromic Substrings](./code/007-Palindromic-Substrings.cpp)
19 | 20 | --- 21 | 22 | -------------------------------------------------------------------------------- /03-competitive-programming/modules/016-String-Algorithms/assets/String-Algorithms.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/016-String-Algorithms/assets/String-Algorithms.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/016-String-Algorithms/code/001-Pattern-Matching-Naive.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Given 2 string (s, p). We need to find if p is a matching pattern in s. 7 | */ 8 | 9 | // Complexity - O(n*m) 10 | bool isMatching(string s, string p){ 11 | int n = s.length(); 12 | int m = p.length(); 13 | for(int i=0; i> s >> p; 31 | 32 | isMatching(s, p) ? cout << "YES" << endl : cout << "NO" << endl; 33 | 34 | return 0; 35 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/016-String-Algorithms/code/002-Longest-Prefix-Suffix.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Optimized algorithm which is use din KMP algorithm for pattern matching. 7 | */ 8 | 9 | int* getLongestPrefixSuffix(string pattern) { 10 | int len = pattern.length(); 11 | int* lps = new int[len]; 12 | 13 | lps[0]=0; 14 | int i=1, j=0; 15 | 16 | while(i < len){ 17 | if(pattern[i] == pattern[j]){ 18 | lps[i] = j+1; 19 | j++; 20 | i++; 21 | } else { 22 | if (j != 0) { 23 | j = lps[j-1]; 24 | } else { 25 | lps[i] = 0; 26 | i++; 27 | } 28 | } 29 | } 30 | return lps; 31 | } 32 | 33 | int main() { 34 | string s = "adadabadadadadadabs"; 35 | int* arr = getLongestPrefixSuffix(s); 36 | for(int i=0; i 2 | 3 | using namespace std; 4 | 5 | int longestPalindromicSubstring(string s){ 6 | int maximum = 0; 7 | int n = s.length(); 8 | for(int i=0; i= 0 && r maximum){ 14 | maximum = curr_l; 15 | } 16 | l--; 17 | r++; 18 | } 19 | 20 | // even length 21 | l=i, r=i+1; 22 | while(l >= 0 && r maximum){ 25 | maximum = curr_l; 26 | } 27 | l--; 28 | r++; 29 | } 30 | } 31 | return maximum; 32 | } 33 | 34 | int main() { 35 | string s; 36 | cin >> s; 37 | cout << longestPalindromicSubstring(s) << endl; 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/017-Tries/README.md: -------------------------------------------------------------------------------- 1 | # Trie 2 | 3 | 4 | ## Notes 5 | 6 | [Click here for Tries](./assets/Tries.pdf)
7 | 8 | --- 9 | 10 | ### Problems 11 | 12 | [001 - XOR Maximum Pair](./code/001-XOR-Maximum-Pair.cpp)
13 | [002 - Maximum XOR subarray](./code/002-Maximum-XOR-subarray.cpp)
14 | [003 - SUBXOR](./code/003-SUBXOR.cpp)
15 | [004 - Sarch Engine](./code/004-Search-Engine.cpp)
16 | [005 - Help Me Pradyumana](./code/005-Help-Me-Pradyumana.cpp)
17 | 18 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/017-Tries/assets/Tries.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/017-Tries/assets/Tries.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/018-Fenwick-Tree/README.md: -------------------------------------------------------------------------------- 1 | # Fenwick Tree (Binary Index Tree) 2 | 3 | - Similar to Segment Tree concept and is best suited when we want to work problems 4 | related to range. 5 | 6 | --- 7 | 8 | ## Notes 9 | 10 | [Click here for Fenwick Tree](./assets/Fenwick-Tree.pdf)
11 | 12 | --- 13 | 14 | 15 | ### Problems 16 | 17 | [001 - Fenwick Tree Operations](./code/001-Fenwick-Tree-Oper.cpp)
18 | [002 - Coders Rating](./code/002-Coders-Rating.cpp)
19 | [003 - Distinct Query Problem](./code/003-Distinct-Elements.cpp)
20 | [004 - OrderSet](./code/004-Order-Set.cpp)
21 | 22 | --- 23 | 24 | ### Assignment 25 | 26 | [001 - KQUERY](./code/005-KQUERY.cpp)
27 | [002 - Shil and Wave Sequence](./code/006-Shil-And-Wave-Sequence.cpp)
28 | [003 - INCSEQ](./code/007-INCSEQ.cpp)
29 | 30 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/018-Fenwick-Tree/assets/Fenwick-Tree.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/018-Fenwick-Tree/assets/Fenwick-Tree.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/019-DP-And-Bitmasking/README.md: -------------------------------------------------------------------------------- 1 | # DP and Bitmasking 2 | 3 | ## Notes 4 | 5 | [Click here for DP and Bitmasking](./assets/DP-And-Bitmasking.pdf)
6 | 7 | --- 8 | ### Problems 9 | 10 | [001 - Minimum Job Cost](./code/001-Minimum-Job-Cost.cpp)
11 | [002 - Candy](./code/002-Candy.cpp)
12 | [003 - Ghost Type](./code/003-Ghost-Type.cpp)
13 | [004 - Dilemma](./code/004-Dilemma.cpp)
14 | [005 - Mehta And Bank Robbery](./code/005-Mehta-And-Bank-Robbery.cpp)
15 | [006 - String Maker](./code/006-String-Maker.cpp)
16 | [007 - Counting Strings](./code/007-Counting-Strings.cpp)
17 | [008 - Number of APs](./code/008-Number-Of-APs.cpp)
18 | 19 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/019-DP-And-Bitmasking/assets/DP-And-Bitmasking.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/019-DP-And-Bitmasking/assets/DP-And-Bitmasking.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/020-Number-Theory-1/README.md: -------------------------------------------------------------------------------- 1 | # Number Theory - 1 2 | 3 | ## Notes 4 | 5 | [Click here for Number Theory 1](./assets/Number-Theory-1.pdf)
6 | [Click here for Applications of NT 1](./assets/Number-Theory-2.pdf)
7 | 8 | --- 9 | 10 | ### Problems 11 | 12 | [001 - Find Prime Numbers From 1 to N](./code-part-1/001-Find-Prime-Numbers-1-to-N.cpp)
13 | [002 - Sieve of Eratosthenes](./code-part-1/002-Sieve-Of-Eratosthenes.cpp)
14 | [003 - GCD - Euclid's Algorithm](./code-part-1/003-GCD-Euclid-Algorithm.cpp)
15 | [004 - Extended Euclid's Algorithm](./code-part-1/004-Extended-Euclid-Algorithm.cpp)
16 | [005 - Multiplicative Modulo Inverse](./code-part-1/005-Multiplicative-Modulo-Inverse.cpp)
17 | 18 | --- 19 | 20 | ### Applications of NT - 1 21 | 22 | [001 - Sachin and Varun problem](./code-part-2/001-Sachin-And-Varun-Problem.cpp)
23 | [002 - Advanced GCD](./code-part-2/002-Advanced-GCD.cpp)
24 | [003 - Divisors of Factorial](./code-part-2/003-Divisors-Of-Factorial.cpp)
25 | [004 - Find the Cube free number](./code-part-2/004-Find-The-Cube-Free-Number.cpp)
26 | [005 - Number of Factors](./code-part-2/005-Number-Of-Factors.cpp)
27 | [006 - Find the Good Sets](./code-part-2/006-Find-the-good-sets.cpp)
28 | [007 - Card Game](./code-part-2/007-Card-Game.cpp)
29 | [008 - Strange Order](./code-part-2/008-Strange-Order.cpp)
30 | 31 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/020-Number-Theory-1/assets/Number-Theory-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/020-Number-Theory-1/assets/Number-Theory-1.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/020-Number-Theory-1/assets/Number-Theory-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/020-Number-Theory-1/assets/Number-Theory-2.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/020-Number-Theory-1/code-part-1/001-Find-Prime-Numbers-1-to-N.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Find Prime Numbers From 1 to N 7 | * - Given a number N, find number of primes in the range [1,N]. 8 | * 9 | * Input: 10 | * The only line of input consists of a number N 11 | * Output: 12 | * Print the number of primes in the range [1,N].` 13 | * Constraints: 14 | * 1≤N≤1000000 15 | * 16 | * Sample Input : 17 | * 3 18 | * Sample Output - 19 | * 2 20 | */ 21 | bool checkPrime(int n){ 22 | int countFactors = 0; 23 | for(int i=1; i*i<=n; i++){ 24 | if((n%i)==0){ 25 | if(i*i == n){ 26 | countFactors += 1; 27 | } else { 28 | countFactors +=2; 29 | } 30 | } 31 | } 32 | return (countFactors==2); 33 | } 34 | 35 | int main() { 36 | int n; 37 | cin >> n; 38 | 39 | int count=0; 40 | for (int i=1; i<=n; i++){ 41 | if(checkPrime(i)){ 42 | count++; 43 | } 44 | } 45 | cout << count << endl; 46 | 47 | return 0; 48 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/020-Number-Theory-1/code-part-1/002-Sieve-Of-Eratosthenes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Find Prime Numbers From 1 to N 7 | * - Given a number N, find number of primes in the range [1,N]. 8 | * 9 | * Input: 10 | * The only line of input consists of a number N 11 | * Output: 12 | * Print the number of primes in the range [1,N].` 13 | * Constraints: 14 | * 1≤N≤1000000 15 | * 16 | * Sample Input : 17 | * 3 18 | * Sample Output - 19 | * 2 20 | */ 21 | 22 | // sieve of eratosthenes - N*log(log(N)) 23 | int makeSieve(int n){ 24 | bool isPrime[n+1]; 25 | for(int i=0; i<=n ; ++i) { 26 | isPrime[i] = true; 27 | } 28 | isPrime[0] = isPrime[1] = false; 29 | for(int i=2; i*i<=n; i++) { 30 | if(isPrime[i]) { 31 | for(int j=i*i; j<=n; j+=i) { 32 | isPrime[j] = false; 33 | } 34 | } 35 | } 36 | int count=0; 37 | for(int i=0; i<=n; i++) { 38 | if(isPrime[i]){ 39 | ++count; 40 | } 41 | } 42 | return count; 43 | } 44 | 45 | int main(){ 46 | int n; 47 | cin >> n; 48 | int numPrimes = makeSieve(n); 49 | cout << numPrimes << '\n'; 50 | return 0; 51 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/020-Number-Theory-1/code-part-1/003-GCD-Euclid-Algorithm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * GCD 7 | * - Calculate and return GCD of two given numbers x and y. Numbers are within 8 | * range of Integer. 9 | * Input format : 10 | * x and y (separated by space) 11 | * Output format : 12 | * GCD of x and y 13 | * 14 | * Sample Input 1: 15 | * 20 16 | * 5 17 | * Sample Output 1: 18 | * 5 19 | * 20 | * Sample Input 2: 21 | * 96 22 | * 14 23 | * Sample Output 2: 24 | * 2 25 | */ 26 | 27 | // Time complexity - Euclid's Algorithm - O(log(max(a, b))) 28 | int gcd(int a, int b){ 29 | //special case 30 | if(a> x >> y; 43 | cout << gcd(x, y) << endl; 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/020-Number-Theory-1/code-part-1/004-Extended-Euclid-Algorithm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Triplet{ 6 | public: 7 | int x, y, gcd; 8 | }; 9 | 10 | Triplet extendedEuclid(int a, int b){ 11 | //Base case 12 | if(b==0){ 13 | Triplet ans; 14 | ans.gcd = a; 15 | ans.x = 1; 16 | ans.y = 0; 17 | return ans; 18 | } 19 | //Extended Euclid Algorithm 20 | Triplet smallAns = extendedEuclid(b, a%b); 21 | Triplet ans; 22 | ans.gcd = smallAns.gcd; 23 | ans.x = smallAns.y; 24 | ans.y = smallAns.x - (a/b)*smallAns.y; 25 | return ans; 26 | } 27 | 28 | int main() { 29 | int a=16; 30 | int b=10; 31 | Triplet ans = extendedEuclid(a, b); 32 | cout << ans.gcd << endl; 33 | cout << ans.x << endl; 34 | cout << ans.y << endl; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/020-Number-Theory-1/code-part-1/005-Multiplicative-Modulo-Inverse.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Triplet{ 6 | public: 7 | int x, y, gcd; 8 | }; 9 | 10 | Triplet extendedEuclid(int a, int b){ 11 | if (b == 0){ 12 | Triplet ans; 13 | ans.x = 1; 14 | ans.y = 0; 15 | ans.gcd = a; 16 | return ans; 17 | } 18 | Triplet smallAns = extendedEuclid(b, a % b); 19 | Triplet ans; 20 | ans.gcd = smallAns.gcd; 21 | ans.x = smallAns.y; 22 | ans.y = smallAns.x - smallAns.y*(a/b); 23 | return ans; 24 | } 25 | 26 | int multiplicativeModuloInverse(int a, int m){ 27 | Triplet ans = extendedEuclid(a, m); 28 | return ans.x; 29 | } 30 | 31 | int main(){ 32 | int a=5; 33 | int m=12; 34 | int ans = multiplicativeModuloInverse(a, m); 35 | cout << ans << endl; 36 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/021-Number-Theory-2/README.md: -------------------------------------------------------------------------------- 1 | # Number Theory - 2 2 | 3 | 4 | ## Notes 5 | 6 | [Click here for Number Theory 2](./assets/Number-Theory-3.pdf)
7 | 8 | --- 9 | 10 | ### Problems 11 | 12 | [001 - Euler's Totient Function](./code/001-Euler-Totient-Function.cpp)
13 | [002 - LCM SUM](./code/002-LCM-SUM.cpp)
14 | [003 - Segment Sieve](./code/003-Segment-Sieve.cpp)
15 | 16 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/021-Number-Theory-2/assets/Number-Theory-3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/021-Number-Theory-2/assets/Number-Theory-3.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/021-Number-Theory-2/code/001-Euler-Totient-Function.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Euler Totient Function 7 | * Ø(n) -> Number of 'm' such that 1<=m 2 | 3 | using namespace std; 4 | 5 | /** 6 | * LCM SUM 7 | * - Given n, calculate and print the sum : 8 | * LCM(1,n) + LCM(2,n) + .. + LCM(n,n) 9 | * where LCM(i,n) denotes the Least Common Multiple of the integers i and n. 10 | * 11 | * Input Format : 12 | * Line 1 : Integer n 13 | * Output Format : 14 | * Required sum 15 | * Constraints : 16 | * 1 <= T <= 300000 17 | * 1 <= n <= 1000000 18 | * 19 | * Sample Input 1 : 20 | * 5 21 | * Sample Output 1 : 22 | * 55 23 | * 24 | * Sample Input 2 : 25 | * 2 26 | * Sample Output 2 : 27 | * 4 28 | */ 29 | 30 | 31 | typedef long long int ll; 32 | 33 | ll gcd(ll a, ll b){ 34 | if(a 7 | 8 | --- 9 | 10 | ### Problems 11 | 12 | [001 - Modular Exponentiation](./code/001-Modular-Exponentiation.cpp)
13 | [002 - Nth Fibonacci Number](./code/002-Nth-Fibonaaci-Number.cpp)
14 | [003 - Fibonacci Sum](./code/003-Fibonacci-Sum.cpp)
15 | [004 - Fermet's Little Theorem](./code/004-Fermats-Little-Theorem.cpp)
16 | [005 - Wilson Theorem](./code/005-Wilson-Theorem.cpp)
17 | [006 - Boring Factorials](./code/006-Boring-Factorials.cpp)
18 | [007 - Income on Nth Day](./code/007-Income-On-Nth-Day.cpp)
19 | 20 | --- 21 | 22 | ### Assignment 23 | 24 | [001 - Cubic Square](./code/008-Cubic-Square.cpp)
25 | [002 - GCD Extreme](./code/009-GCD-Extreme.cpp)
26 | [003 - Sanchit And Nuclear Reactor](./code/010-Sanchit-And-Nuclear-Reactor.cpp)
27 | [004 - Innocent Swaps and His Emotions](./code/011-Innocent-Swaps-and-His-Emotions.cpp)
28 | [005 - Sehwag And ETF](./code/012-Sehwag-And-ETF.cpp)
29 | 30 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/022-Number-Theory-3/assets/Number-Theory-4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/022-Number-Theory-3/assets/Number-Theory-4.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/022-Number-Theory-3/code/001-Modular-Exponentiation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Calculate (a^b % mod) 7 | */ 8 | 9 | // Recursive Approach 10 | int modularExponentiation(int a, int b, int mod){ 11 | if(a==0){ 12 | return 0; 13 | } 14 | if(b==0){ 15 | return 1; 16 | } 17 | long ans; 18 | if(b%2==0){ 19 | long smallAns = modularExponentiation(a, b/2, mod); 20 | ans = (smallAns*smallAns) % mod; 21 | } else { 22 | long smallAns = modularExponentiation(a, b-1, mod); 23 | ans = (a%mod); 24 | ans = (ans*smallAns) % mod; 25 | } 26 | return int((ans+mod) % mod); 27 | } 28 | 29 | // Iterative Approach 30 | int modularExponentiationIterative(int a, int b, int mod){ 31 | int ans=1; 32 | while(b){ 33 | if(b%2 == 1){ 34 | ans = (ans*a) % mod; 35 | } 36 | a = (a*a) % mod; 37 | b = b/2; 38 | } 39 | return ans; 40 | } 41 | 42 | int main() { 43 | int a = 2; 44 | int b = 2783; 45 | int mod = 5; 46 | cout << modularExponentiation(a, b, mod) << endl; 47 | cout << modularExponentiationIterative(a, b, mod) << endl; 48 | 49 | return 0; 50 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/023-Game-Theory/README.md: -------------------------------------------------------------------------------- 1 | # Game Theory 2 | 3 | 4 | ## Notes 5 | 6 | [Click here for Game Theory](./assets/Game-Theory.pdf)
7 | 8 | --- 9 | 10 | ### Problems 11 | 12 | [001 - Calculate Grundy Number](./code/001-Calculate-Grundy-Number.cpp)
13 | [002 - Othello](./code/002-Othello.cpp)
14 | [003 - Optimal Move in Tic Tac Toe](./code/003-Optimal-Move-In-Tic-Tac-Toe.cpp)
15 | 16 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/023-Game-Theory/assets/Game-Theory.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/023-Game-Theory/assets/Game-Theory.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/023-Game-Theory/code/001-Calculate-Grundy-Number.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /** 6 | * Mex : Minimum Excludent Set i.e. smallest non-negative value not present in set. 7 | * 8 | * Calculate Grundy Number 9 | * - Calculate the Grundy Number for the given 'n' in the game. 10 | * - The game starts with a number- ‘n’ and the player to move divides the 11 | * number- ‘n’ with 2, 3 or 6 and then takes the floor. If the integer becomes 12 | * 0, it is removed. The last player to move wins. Which player wins the game? 13 | * 14 | * Input Format 15 | * An Integer 'n' 16 | * Output Format 17 | * Grundy Number(n) 18 | * 19 | * Sample Input 1 - 20 | * 10 21 | * Sample Output 1- 22 | * 0 23 | */ 24 | 25 | #include 26 | 27 | int mex(int a, int b, int c){ 28 | unordered_sets; 29 | s.insert(a); 30 | s.insert(b); 31 | s.insert(c); 32 | for(int i=0; i> n; 49 | cout << grundy(n) << endl; 50 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/024-Computational-Geometry/README.md: -------------------------------------------------------------------------------- 1 | # Computational Geometry 2 | 3 | 4 | ## Notes 5 | 6 | [Click here for Computational Geometry](./assets/Computational-Geometry.pdf)
7 | 8 | --- 9 | 10 | ### Problems 11 | 12 | [001 - Area of a Polygon](./code/001-Area-Of-A-Polygon.cpp)
13 | [002 - Area of Convex Polygon](./code/002-Area-Of-Convex-Polygon.cpp)
14 | [003 - Surveyor](./code/003-Surveyor.cpp)
15 | [004 - Warehouse](./code/004-Warehouse.cpp)
16 | [005 - Convex Hull](./code/005-Convex-Hull.cpp)
17 | 18 | --- -------------------------------------------------------------------------------- /03-competitive-programming/modules/024-Computational-Geometry/assets/Computational-Geometry.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/03-competitive-programming/modules/024-Computational-Geometry/assets/Computational-Geometry.pdf -------------------------------------------------------------------------------- /03-competitive-programming/modules/024-Computational-Geometry/code/001-Area-Of-A-Polygon.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Point{ 6 | public: 7 | double x, y; 8 | }; 9 | 10 | class Polygon{ 11 | public: 12 | Point* points; 13 | 14 | Polygon(int nPoints){ 15 | points = new Point[nPoints]; 16 | } 17 | 18 | }; 19 | 20 | double area(Polygon p, int n){ 21 | double totalArea=0; 22 | for(int i=1; i> n; 37 | Polygon p(n); 38 | cout << "Enter the coordinates of Polygon" << endl; 39 | for(int i=0; i> p.points[i].x >> p.points[i].y; 41 | } 42 | cout << "Area of Polygon is " << area(p, n) << endl; 43 | } -------------------------------------------------------------------------------- /03-competitive-programming/modules/025-FFT/README.md: -------------------------------------------------------------------------------- 1 | # FFT 2 | 3 | 4 | ### Problems 5 | 6 | [001 - FFT](./code/001-FFT.cpp)
7 | 8 | --- -------------------------------------------------------------------------------- /04-aptitude/README.md: -------------------------------------------------------------------------------- 1 | 2 |

Interview Preparation | Aptitude Rounds

3 |
4 | 5 | # Problems 6 | 7 | [001 - HCF and LCM](./modules/001-HCF-and-LCM.cpp)
8 | [002 - Averages](./modules/002-Averages.cpp)
9 | [003 - Alligations](./modules/003-Alligations.cpp)
10 | [004 - Percentages](./modules/004-Percentages.cpp)
11 | [005 - Ratio, Proportions and Variation](./modules/005-Ratio-Proportaion-Variation-1.cpp)
12 | [006 - Profit and Loss](./modules/006-Profit-And-Loss.cpp)
13 | [007 - Ratio, Proportions and Variation - 2](./modules/007-Ratio-Proportaion-Variation-2.cpp)
14 | [008 - Time and Work](./modules/008-Time-Ans-Work.cpp)
15 | [009 - Reasoning](./modules/009-Reasoning-1.cpp)
16 | [010 - Permutation and Combination](./modules/010-Permutation-Combination.cpp)
17 | [011 - Probability](./modules/011-Probability.cpp)
18 | [012 - Time, Speed and Distance](./modules/012-Time-Speed-Distance.cpp)
19 | [013 - Blood Relation Calenders](./modules/013-Blood-Relation-Calenders.cpp)
20 | [014 - Applications of Time, Speed and Distance](./modules/014-Applications-Of-Time-Speed-Distance.cpp)
21 | [015 - Set Theory Mensuration](./modules/015-Set-Theory-Mensuration-Log.cpp)
22 | [016 - Important Topics](./modules/016-Important-Topics.cpp)
23 | 24 | --- -------------------------------------------------------------------------------- /05-introduction-to-os/assets/01-Introduction-of-OS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/01-Introduction-of-OS.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/02-Installation-Of-Ubuntu-In-Virtual-Machine.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/02-Installation-Of-Ubuntu-In-Virtual-Machine.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/03-Introduction-to-Linux-Terminal.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/03-Introduction-to-Linux-Terminal.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/04-Summary-Document-Introduction-of-OS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/04-Summary-Document-Introduction-of-OS.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/05-Introduction-to-Process.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/05-Introduction-to-Process.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/06-Process-Scheduling-Algorithms-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/06-Process-Scheduling-Algorithms-1.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/07-Preemptive-SJF-And-RR-Scheduling-Algorithms.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/07-Preemptive-SJF-And-RR-Scheduling-Algorithms.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/08-Process-Scheduling-Algorithms-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/08-Process-Scheduling-Algorithms-2.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/09-Memory-Management-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/09-Memory-Management-1.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/10-Functions-in-C-for-Memory-Management.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/10-Functions-in-C-for-Memory-Management.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/11-Memory-Management-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/11-Memory-Management-2.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/12-Non-Contiguous-Memory-Allocation-and-Virtual-Memory.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/12-Non-Contiguous-Memory-Allocation-and-Virtual-Memory.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/13-Concurrency-Introduction.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/13-Concurrency-Introduction.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/14-Concurrency-Key-Notes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/14-Concurrency-Key-Notes.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/15-Failed-Attempt-To-Solve-Race-Condition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/15-Failed-Attempt-To-Solve-Race-Condition.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/16-Petersons-Solution.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/16-Petersons-Solution.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/17-Hardware-And-OS-Support.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/17-Hardware-And-OS-Support.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/18-Producer-And-Consumer-Problem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/18-Producer-And-Consumer-Problem.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/19-Mutexes-Vs-Semaphores.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/19-Mutexes-Vs-Semaphores.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/20-Summary-Concurrency.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/20-Summary-Concurrency.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/21-Introduction-to-Storage-Management.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/21-Introduction-to-Storage-Management.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/22-Introduction-to-Files-and-Directories.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/22-Introduction-to-Files-and-Directories.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/23-Introduction-to-Disk-Space-Allocation-Methods.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/23-Introduction-to-Disk-Space-Allocation-Methods.pdf -------------------------------------------------------------------------------- /05-introduction-to-os/assets/24-Summary-Storage-Management.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/05-introduction-to-os/assets/24-Summary-Storage-Management.pdf -------------------------------------------------------------------------------- /06-system-design/assets/001-Introduction-to-system-design.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/001-Introduction-to-system-design.pdf -------------------------------------------------------------------------------- /06-system-design/assets/002-HLD-And-LLD.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/002-HLD-And-LLD.pdf -------------------------------------------------------------------------------- /06-system-design/assets/003-Monolithic-Architecture.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/003-Monolithic-Architecture.pdf -------------------------------------------------------------------------------- /06-system-design/assets/004-Distributed-System.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/004-Distributed-System.pdf -------------------------------------------------------------------------------- /06-system-design/assets/005-Latency.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/005-Latency.pdf -------------------------------------------------------------------------------- /06-system-design/assets/006-Throughput.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/006-Throughput.pdf -------------------------------------------------------------------------------- /06-system-design/assets/007-Availability.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/007-Availability.pdf -------------------------------------------------------------------------------- /06-system-design/assets/008-Consistency.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/008-Consistency.pdf -------------------------------------------------------------------------------- /06-system-design/assets/009-CAP-Theorem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/009-CAP-Theorem.pdf -------------------------------------------------------------------------------- /06-system-design/assets/010-Time.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/010-Time.pdf -------------------------------------------------------------------------------- /06-system-design/assets/011-Redundancy-And-Replication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/011-Redundancy-And-Replication.pdf -------------------------------------------------------------------------------- /06-system-design/assets/012-Load-Balancers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/012-Load-Balancers.pdf -------------------------------------------------------------------------------- /06-system-design/assets/013-Load-Balancing-Algorithms.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/013-Load-Balancing-Algorithms.pdf -------------------------------------------------------------------------------- /06-system-design/assets/014-Caching.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/014-Caching.pdf -------------------------------------------------------------------------------- /06-system-design/assets/015-Caching-Strategies.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/015-Caching-Strategies.pdf -------------------------------------------------------------------------------- /06-system-design/assets/016-Databases.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/016-Databases.pdf -------------------------------------------------------------------------------- /06-system-design/assets/017-Indexing.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/017-Indexing.pdf -------------------------------------------------------------------------------- /06-system-design/assets/018-Partitioning.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/018-Partitioning.pdf -------------------------------------------------------------------------------- /06-system-design/assets/019-Synchronous-Communication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/019-Synchronous-Communication.pdf -------------------------------------------------------------------------------- /06-system-design/assets/020-Asynchronous-Communication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/020-Asynchronous-Communication.pdf -------------------------------------------------------------------------------- /06-system-design/assets/021-Message-Based-Communication.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/021-Message-Based-Communication.pdf -------------------------------------------------------------------------------- /06-system-design/assets/022-Web-Application.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/022-Web-Application.pdf -------------------------------------------------------------------------------- /06-system-design/assets/023-REST-API.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/023-REST-API.pdf -------------------------------------------------------------------------------- /06-system-design/assets/024-Service-Oriented-Architecture.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/024-Service-Oriented-Architecture.pdf -------------------------------------------------------------------------------- /06-system-design/assets/025-Microservice-Architecture.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/025-Microservice-Architecture.pdf -------------------------------------------------------------------------------- /06-system-design/assets/026-Tier-Architecture.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/026-Tier-Architecture.pdf -------------------------------------------------------------------------------- /06-system-design/assets/027-Web-Servers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/027-Web-Servers.pdf -------------------------------------------------------------------------------- /06-system-design/assets/028-Communication-Protocols.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/028-Communication-Protocols.pdf -------------------------------------------------------------------------------- /06-system-design/assets/029-Proxies.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/029-Proxies.pdf -------------------------------------------------------------------------------- /06-system-design/assets/030-Application-Security.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/06-system-design/assets/030-Application-Security.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/001-Introduction-to-DBMS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/001-Introduction-to-DBMS.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/002-Need-for-DBMS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/002-Need-for-DBMS.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/003-Data-Models.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/003-Data-Models.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/004-Schemas.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/004-Schemas.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/005-Schema-Architecture.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/005-Schema-Architecture.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/006-Advanced-Concepts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/006-Advanced-Concepts.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/007-Relational-Model.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/007-Relational-Model.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/008-Keys.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/008-Keys.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/009-Integrity-Rules-And-Constraints.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/009-Integrity-Rules-And-Constraints.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/010-Relational-Algebra.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/010-Relational-Algebra.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/011-MySQL-Install-Linux.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/011-MySQL-Install-Linux.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/011-MySQL-Install-MacOS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/011-MySQL-Install-MacOS.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/011-MySQL-Install-Windows.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/011-MySQL-Install-Windows.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/012-SQL-Quick-Summary.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/012-SQL-Quick-Summary.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/013-SQL-Datatypes-Summary.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/013-SQL-Datatypes-Summary.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/014-SQL-Commands-Summary.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/014-SQL-Commands-Summary.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/015-Filtering-And-Sorting-Data.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/015-Filtering-And-Sorting-Data.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/016-Grouping-Data-Summary.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/016-Grouping-Data-Summary.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/017-Queries-Tables-Constraints.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/017-Queries-Tables-Constraints.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/018-Modifying-Data.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/018-Modifying-Data.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/019-Joining-Tables.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/019-Joining-Tables.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/020-Set-Operations.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/020-Set-Operations.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/021-SubQuery-And-Types.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/021-SubQuery-And-Types.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/022-SubQuery-Examples.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/022-SubQuery-Examples.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/023-Joins-Vs-Subqueries.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/023-Joins-Vs-Subqueries.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/024-Transaction-Statement.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/024-Transaction-Statement.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/025-Import-Export.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/025-Import-Export.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/026-Functional-Dependency.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/026-Functional-Dependency.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/027-Anomalies.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/027-Anomalies.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/028-Normalisation-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/028-Normalisation-1.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/028-Normalisation-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/028-Normalisation-2.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/029-Transaction-ACID-Properties.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/029-Transaction-ACID-Properties.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/030-Transaction-States.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/030-Transaction-States.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/031-Indexing-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/031-Indexing-1.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/031-Indexing-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/031-Indexing-2.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/032-Advantages-Disadvantages-NoSQL.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/032-Advantages-Disadvantages-NoSQL.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/033-Key-Value-NoSQL-DB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/033-Key-Value-NoSQL-DB.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/034-Columnar-NoSQL-DB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/034-Columnar-NoSQL-DB.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/035-Document-NoSQL-DB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/035-Document-NoSQL-DB.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/036-Graph-Based-NoSQL-DB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/036-Graph-Based-NoSQL-DB.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/037-Relational-Database.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/037-Relational-Database.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/038-Object-Oriented-Database.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/038-Object-Oriented-Database.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/039-Hierarchical-Database.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/039-Hierarchical-Database.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/040-Network-Database.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/040-Network-Database.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/041-Concurrency-Control.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/041-Concurrency-Control.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/042-Clustering.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/042-Clustering.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/043-Partitioning-Sharding.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/043-Partitioning-Sharding.pdf -------------------------------------------------------------------------------- /07-Introduction-to-DBMS/assets/044-Imp-Functions-And-Commands.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/07-Introduction-to-DBMS/assets/044-Imp-Functions-And-Commands.pdf -------------------------------------------------------------------------------- /08-curated-interview-dsa-problems-java/README.md: -------------------------------------------------------------------------------- 1 | 2 |

Curated DSA Problems

3 |
4 | 5 | ## Modules: 6 | 7 | [001 - Arrays](./modules/001-array)
8 | 9 | --- -------------------------------------------------------------------------------- /08-curated-interview-dsa-problems-java/modules/001-array/README.md: -------------------------------------------------------------------------------- 1 | 2 |

Arrays

3 |
4 | 5 | ### Problems 6 | 7 | [001 - Rearrange In ZigZag Order](./code/P001_Rearrange_In_ZigZag_Order.java)
8 | [002 - 4th Highest element](./code/P002_4th_Highest_element.java)
9 | [003 - Max Profit Selling Gulal](./code/P003_Max_Profit_Selling_Gulal.java)
10 | [004 - Buying And Selling Stocks](./code/P004_Buying_And_Selling_Stocks.java)
11 | [005 - Divide In Three Way](./code/P005_Divide_In_Three_Way.java)
12 | [006 - Non Decreasing Array Convertible](./code/P006_Non_Decreasing_Array_Convertible.java)
13 | [007 - Trapped Water In Bars](./code/P007_Trapped_Water_In_Bars.java)
14 | [008 - Subarray Sum Of Infinite Array](./code/P008_Subarray_Sum_Of_Infinite_Array.java)
15 | [009 - Ninja Vs Board](./code/P009_Ninja_Vs_Board.java)
16 | [010 - Design Browser History](./code/P010_Design_Browser_History.java)
17 | 18 | --- -------------------------------------------------------------------------------- /pre-placement-checklist-questions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-ninja-dsa-competitive-package/codig-ninja-dsa-learning/d5987529ba4b3f4f618798e4c658c1cf423d513f/pre-placement-checklist-questions.pdf --------------------------------------------------------------------------------