├── .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