• README
  • home
    • 1 motivation
    • 2 resources
    • 3 roadmap
    • 4 resource itineraries
      • 1 CN Intro to Cpp
        • 1. Flowcharts
          • 0 index
          • 1. Intro to flowcharts
          • 2. Decision Making
          • 3. Loops
          • 4. Largest of N numbers
          • 5. Assignments
          • Conclusion
        • 10. Multidimensional Arrays
          • 0 index
          • Assignments
        • 2. C++, W2H
          • 1. About C++
          • 2. Why learn C++
          • 3. C++ Setup
        • 3. main, Variables and Operators
          • 0 index
          • 1. First Program
          • 2. Variables and data types
            • 0 index
            • 2.1 Type Aliases
            • 2.2 Automatic Type Deductions
              • 1. auto
                • 0 index
              • 2. decltype
          • 4. How is the data stored
          • 5. How are negative numbers stored
          • 6. Operators
        • 4. Conditionals and while loops
          • 0 index
          • 1. Conditionals
          • 2. Farenheit to Celsius
          • 3. Patterns
          • 4. Pratice problems
            • 1. Patterns 1
              • 0 index
              • 1. Pattern1
              • 2. Square Patterns
              • 3. Triangle Patterns
              • 4. Character Pattern
              • 5. Interesting Alphabets
            • 2. Patterns 2
              • 1. Mirror Triangles
              • 2. Isosceles Triangle
              • 3. More Patterns
        • 5. For loop and bitwise ops
          • 1. Bitwise Operator
          • 2. Increment Operators
          • 3.0 For loop
          • 3.1 For each loop
          • 4. Break and continue
          • 5. Scope of variables
          • 6. cin vs cin.get()
          • 7. Assignments
        • 6. Functions
          • 0 index
          • 1. What are functions
          • 2. How function calling works
          • 3. Scope of variables w.r.t functions
          • 4. Call by Value
        • 7. Arrays
          • 0 index
          • 1. Why arrays
          • 2. More On Arrays
            • 0 index
          • 3. Arrays and memory
          • 4. Arrays as function parameters
          • 5. Assignments
        • 8. Searching and Sorting
          • 0 index
          • 1.Linear Search
          • 2. Binary Search
          • 3. Merging two sorted arrays
          • 4. Bubble Sort
          • 5. Insertion Sort
          • 6. Selection Sort
          • Analyzing sorting algorithms
          • Assignments
            • 0 index
        • 9. Stringsx
        • Home
        • notebook
      • 2 CN Data Structures and OOP
        • 1. Memory and Pointers
          • 0 index
          • 1. Pointers
            • 0 index
            • 1. Pointer Intro
            • 2. Pointer Arithmetic
            • 3. Arrays and Pointers
              • 0 index
              • Assignment questions
              • questionnaire1&2&3
            • 4. Characters and Pointers
            • 5. Function and Pointers
            • 6. Nested pointer
              • 0 index
              • questionnaire4&5&6
            • 7. Address Typecasting
            • 8. References and Pass by Reference
          • 2. Dynamic Memory Allocation
            • 1. Dynamic Allocation
            • 2. Dynamic Memory Allocation of 2D arrays
            • questionnaire1
        • 2. Time and Space Analysis
          • 0 index
          • 1. Time
            • 1. Order Complexity Analysis
              • 0 index
            • 2. Linear Search Time Complexity
            • 3. Insertion Sort
            • 4. Selection Sort
            • 5. Time complexity for recursive algorithms
              • 0 index
            • 6. Fibonacci is bad
          • 2. Space
          • exerciseques
          • zAssignments
            • 0 index
            • after assignments
        • 3. Binary Search Trees
          • Quizzes&Exercises
            • Exercises
          • zAssignments
            • Assignments
        • 3. Recursion
          • 1. Recursion Basics
            • 0 index
            • 1. Intro to Recursion
            • 2. Recursion and PMI
            • 3. Fibonacci Number
            • 4. Recursion with Arrays
            • 5. Approach for recursive problems
            • questionnare2
            • zAssignments
              • 0 index
              • after assignments
              • lect assignments
          • 2. Recursion Practice
            • assignments
          • 3. Applications of Recursion
            • 0 index
            • 1. Recursion and Strings
              • 0 index
              • assignments
              • ms and qs
            • 2. Merge Sort
            • 3. Quick Sort
            • 4. Strings
            • zAssignments
              • 0 index
              • 1. Subsequences of Strings
                • 0 index
                • lectureCodes
              • 2. Printing subsequence
                • 0 index
              • after assignments
          • Test1
        • 4. OOP Basics
          • 0 index
          • 1. Intro and syntax
            • 0 index
            • 1. Principles of OOP
            • 2. Classes
            • 3. Objects
            • 4. Functions(in class)
              • 1. Getters and Setters
                • 0 index
              • 2. Core member functions
            • 5. this keyword
            • exercise ques
          • 2. Special Functions
            • 0 index
            • 1. Constructor idea and syntax
              • 0 index
              • 1. The Copy constructor
                • 0 index
                • 1. Shallow and Deep copy
              • 2. Feature Delegating constructors
            • 2. Destructor
            • 3. Special functions details
              • 0 index
          • 3. Member constraints
            • 0 index
            • 1. const
              • 1. const fields Intialization List
              • 2. const member functions
            • 2. static
          • 4. Operator overloading
            • 0 index
            • 1. Binary operator
            • 2. Unary post
              • 0 index
            • 3. Unary pre
            • exercises
            • zAssignment Polynomial class
              • 0 index
          • 5. Separate Compilation
          • 6. Approach for writing a class
        • 5. Data Structures
          • 1. Linear Data Structures
            • 1. Vector aka Dynamic Array
            • 2. Linked List
              • 1. Linked List Basics
                • 0 index
                • 1. What are data structures and why are they important
                • 2. What is a linked list
                • 3. Basic Operations on LL
                  • 1. Length of LL (recursive)
                  • 2. Insert node at the ith position
                  • 3. Delete Node
                  • 4. Delete Node recursive
                  • 5. Insert Node recursive
                  • 6. Print the Linked List
                • 8. Variations of LL
                • Exercises
                • zAssignments
                  • 0 index
                  • 1. Linear Search in LL
                  • 2. AppendLastNToFirst
                  • 3. Eliminate dupicates from the array
                  • 4. Print LL in reverse
                  • 5. Palindrome Linked List
                  • Assignments
              • 2. Popular LL problems
                • 0 index
                • 1. Midpoint of the LL
                • 2. Merging two sorted LLs
                • 3. Merge Sort on LL
                • 4. Reverse LL(recursive)
                • 5. Reverse LL using 2 pointers
                • 6. Reverse LL recursive easiest
                • 7. Reverse LL Iterative
                • zAssignments
                  • Assignments
            • 3. Stack
              • 0 index
              • 1. Introduction to Stacks
              • 2. Stack using arrays
                • 0 index
              • 3. Stack using dynamic arrays
                • 0 index
              • 4. Templates
                • 0 index
              • 5. Stacks with templates
                • 0 index
              • 6. Stack using LL
                • 0 index
              • 7. Inbuilt stack STL
                • 0 index
            • 4. Queue
              • 0 index
              • 1. Queue Introduction
                • 0 index
              • 2. Queue using Array Code
                • 0 index
              • 3. Queue using Dynamic Array Code
                • 0 index
              • 3. zNamespaces
              • 4. Queue using LL
                • 0 index
              • 5. Inbuilt queue STL
                • 0 index
            • zTest 2
              • Test2
          • 2. Trees
            • 1. Generic Trees
              • 0 index
              • 1. Introduction to trees
              • 2. Coding a tree
                • 1. TreeNode class
                  • 0 index
                • 2. Destructor
                • 3. IO for trees
                  • 1. Take input and print recursive
                    • 0 index
                  • 2. Take input levelwise
                  • 3. Output level wise
              • 3. Tree params
                • 1. Number of nodes
                • 2. Height of a tree Exercise
                • 3. Depth of a Node
                  • 0 index
                • 4. Number of leaf nodes
                  • 0 index
              • 4. Tree Traversals
                • 0 index
            • 2 .Binary trees
              • 0 index
              • 1. Intro to Binary trees
              • 2. Coding a Binary Tree
                • 2. Input
                  • 0 index
                • 3. Printing a tree
                  • 0 index
              • 3. Params
                • 1. Count nodes
                • 2. Diameter of a BInary tree
              • 4. Traversals
                • 0 index
              • 5. Construction from traversal
                • 1. Pre and In
                  • 0 index
                • 2. Post and In
                • 3. Level and In
              • zAssignments
                • 0 index
                • Assignments
            • 3. Binary Search Trees
              • 0 index
              • 1. Intro to BST
              • 2. Coding BST BST Node class
                • 0 index
              • 3. Search Operation in BST
              • 4. Common BST questions
                • 1. Check if BST
                  • 1. Check BST 1
                    • 0 index
                  • 2. Check BST 2
                  • 3. Check BST 3
                • 2. Construct BST from sorted array
                • 3. BST to sorted LL
                • 4. Find Path
                  • 0 index
              • 5. Variations of BST
                • 0 index
                • 1. AVL trees
                  • 0 index
          • 3. Auxilary Data Structures
            • 0 index
            • 1. Priority Queue and Heap
              • 0 index
              • 1. Intro to priority queue
              • 2. Intro to Heap
              • 3. The two kinds of heaps
              • 4. Complete Binary Trees
              • 5. Heap Insertion and Deletion
              • 7. In place heap
              • 8. STL priority queue
              • 9. Practice Problems
                • 1. K sorted array
                • 2. K smallest elements
            • 2. Hashmaps
              • 0 index
              • 1. Intro to hashMaps
              • 2. Bucket Array and hash functions
              • 3. Collision Handling
              • 4. Time complexity and time factor
              • 5. Coding a hashMap
              • 7. Question Infinite Stream
              • 8. STL map and set
                • 1. map and unordered map
                  • 0 index
                • 2. set and unordered set
                • 3. Iterators C++ Feature
            • 3. Tries
              • 0 index
              • 1. Introduction to Tries
              • 2. Coding a Trie
                • 1. TrieNode class
                • 2. Trie basic API
              • 3. Types of Tries
                • 0 index
              • 4. Huffman Encoding
          • 4. Graphs
            • 1. Graphs Basics
              • 1. Intro to graphs
              • 2. Graph Terminology
              • 3. Graph varieties
              • 4. Coding a Graph
              • 5. Basic Traversals
                • 1. DFS
                • 2. BFS
              • 6. Basic path operations
                • 1. Has Path
                • 2. Get Path
              • 7. Problem get connected components
            • 2. Graphs 2
              • 0 index
              • 1. Intro to MST
              • 2. Cycle Detection
                • 0 index
              • 2. MST algorithms
                • 1. Kruskal's Algo Complexity
                  • 0. Sorting w.r.t a data member of a class
                  • 0 index
              • 5. Prim's Algorithm
              • 6. Dijkstra's Algorithm
          • 5. C++ STL
            • 0 index
            • 1. pair
            • 2. tuple
            • 3. Bitset
        • 6. Algorithm Design
          • 0. Brute force
          • 0 index
          • 3. Design Techniques
            • 1. Divide and Conquer
            • 2. Greedy
            • 3. Dynamic Programming
              • 0 index
              • 1. Fibonacci 1
                • 0 index
              • 2. Fibonacci 2
              • 3. Min Steps to 1
              • 4. DP summary
              • 5. Practice Problems
                • 0 index
                • 1. Min Cost Path
                • 2. Largest Common Subsequence
                • 3. Edit Distance
          • 4. NP Completeness
        • 7. C++ Continued
          • 0 index
          • 1. Macros and Global Variables
            • 0 index
            • questionnaire5 6 7
          • 2. Inline and Default Arguments
          • 3. const and constexpr
          • 4. Exception Handling
            • 0 index
        • 8. OOP Continued
          • 0 index
          • 1. Relations between classes
            • 0 index
            • 1. Inheritance
              • 1 Inheritance Concept
              • 2 Access specifiers in inheritance
              • 3 Syntax
              • 4 Overriding, Overloading, Delegation
              • 5 1 Types of Inheritance (specifier)
              • 5 2 Types of Inheritance (level)
              • 5 Types of Inheritance
              • 6 Hybrid Inheritance
              • 7 Liskov Substitution Principle 1
              • 7 Liskov Substitution Principle
        • Codes
          • DFS.cpp
        • Home
        • notebook
      • 3 CN Competitive programming
        • 1. CP intro and tools
          • 1. Intro to Competitive Programming
            • 1. What is CP
            • 2. Why CP
            • 3. Various Types of Errors
            • 4. How to approach a problem in a competitive programming contest
              • 0 index
              • a. Reading problem statements
              • b. IO Format
              • c. Constraints
                • 0 index
          • 2. Time and Space Complexity
            • 0 index
            • Problems
              • 1. Kadane's Algorithm
              • 2. LeftRight Sum
          • 3. IO Techniques
            • 0 index
            • 1. Console streams
            • 2. C++ File streams
              • 0 index
              • 1. Writing to a file
              • 2. Reading from a file
              • 3. Serialization
            • 3. General tricks
          • 4. Language Tools
            • 0 index
            • 1. STL Data Structures
              • 0. Conveniences
                • 1. pair
                • 2. tuple
              • 0 index
              • 1. Physical Data Structures
                • 1. Vector
                  • 0 index
                • 2. List
              • 2. ADTs
                • 2. String
                • 4. Stack
                • 5. Queue
                • 6. Map
                • 7. Set
                  • 0 index
                • 8. Prioirty Queue
            • 2. Functions
              • 0 index
              • 1. Sorting
              • 2. Searching
                • 0 index
              • 3. Math functions
              • 4. Utility functions
            • 3. Hussain Set
              • 0 index
        • 10. TreesX
          • 0 index
          • 1. Tries
            • 0 index
            • 1. Tries and XOR
            • 2. Maximum XOR value of subarray
          • 2. Segment Tree
            • 1. Introduction To Segment Tree
            • 2. Building a segment tree
            • 3. Update on a segment tree
            • 4. Query on a Segment Tree
            • 5. Size of a segment tree
            • Assignments
              • 0 index
            • zAssignments
              • 0 index
          • 3. Fenwick Tree
        • 11. Number Theory
          • 1. Modulo Arithmetic
            • 0 index
            • 1. Modulo operation
              • 0 index
            • 2. Modulo properties
            • 3. Modulo properties continued
            • 4. Exercise number of Binary Trees
              • 0 index
          • 2. Prime generator and GCD
            • 1. Primes
              • 1. Find prime numbers between 1 and N
              • 2. Sieve of Eratosthenes
                • 0 index
              • 3. Complexity of Sieve of Eratosthenes
            • 2. Euclid's Algo
              • 1. GCD Euclid's Algorithm
              • 2. Complexity of Euclid's GCD algorithm
              • 3. Diophantine Equations
                • 0 index
              • 4. Extended Euclidean Algorithm
                • 0 index
            • 3. Multiplicative Modulo Inverse
            • 4. Applications Of NT 1
              • 1. Sachin and Varun
                • 0 index
              • 2. Advanced GCD
          • 3. Totient Function
            • 1. Euler's Totient Function
            • 2. LCM Sum
          • 4. Solving equations using NT
            • 1. Optimized Power Function
              • 0 index
            • 2. Modular exponentiation
              • 0 index
            • 3. Matrix Exponentiation
              • 0 index
              • 1. Matrix Exponentiation More Recurrence Relation
              • 2. Matrix Expo Fibonacci Sum
            • 4. Fermat's Little Theorem
              • 0 index
            • 5. Wilson's Theorem
            • 6. Income on the Nth day
        • 12. Game Theory
          • 1. Intro to Game Theory
          • 2. Game of Nim
          • 3. Proof of Nim Formula
          • 4. Grundy Numbers
          • 5. Sprague Grundy Theorem
          • 6. MinMax Algorithm
        • 13. Computational Geometry
          • 0 index
          • 1. Intro to Computational Geometry
          • 2. Distance betwn point and line
          • 3. Area of a polygon
          • 4. Intersection of two lines
          • 5. Convex Hull
        • 14. FFT
        • 15. HLD
          • 0 index
          • 1. Intro to HLD
          • 2. Basics of HLD
          • 3. Importance of HLD
          • 4. Complexity of operations
        • 2. Unconventional use of Searching And Sorting
          • 0 index
          • 1. Aggressive Cows
          • 2. Inversion Count
            • 0 index
          • 3. chef
            • 0 index
          • 4. Variation
            • 0 index
          • 5. Murder
            • 0 index
          • 6. Momos Market
            • type
          • 7. Distribute Candies
            • distribute candies
          • 8. Taj Mahal Entry
            • 0 index
        • 3. RecursionX
          • 1. BackTracking
            • 0 index
            • 1. N Queens Problem Exercise
              • 0 index
            • 2. Rat And Maze problem
              • 0 index
            • 3. Sudoku Puzzle
              • 0 index
            • 4. Crossword Problem
              • 0 index
          • 2. BackTracking Assignment BackTracking, Binary Search And Merge Sort Problems
            • 1. Find Power of number
            • 2. Sorting the Skills
            • 3. Collecing the balls
            • 4. Sudoku Solver
        • 4. Bit Manipulation
          • 0 index
          • 1. Shift Operators
            • 0 index
          • 2. Remaining Bitwise Operators
            • 0 index
          • 3. ith bit
            • 0 index
          • 4. Flipping a specific bit
          • 5. Check if oddeven
          • 6. Check if number is power of 2
          • 7. First Set bit
          • 8. Clear all bits from the LSB
        • 5. Adhoc Problems
          • 0 index
          • 1. Equalize CodeForces
            • 0 index
          • 2. Rectangular Area
            • 0 index
          • 3. Light up the bulbs
            • 0 index
          • 4. Circular List of students
            • 0 index
          • 5. Interesting Sequences
            • 0 index
          • 6. Winning Strategy
            • 0 index
        • 6. Dynamic ProgrammingX
          • 0 index
          • 1. Classic problems
            • 0 index
            • 1. DP Basics Fibonacci Number
              • 0 index
            • 2. AlphaCode
              • 0 index
            • 3. Longest Increasing subsequence
              • 0 index
            • 4. Largest Bitonic Subsequence
              • 0 index
            • 5. Coin change and stair case
              • 0 index
            • 6. Minimum Cost
              • 0 index
            • 7. Magic Grid
              • 0 index
            • Assignments 1
              • 1. Loot Houses 80
              • 2. Maximum Square Matrix With All Zeros 80
              • 3. Count BSTs 80
              • 4. Boredom 80
              • 5. Minimum Number of Chocolates 80
              • 6. Minimum Count 80
            • Assignments 2
              • 1. Hasan and Trip 40
              • 2. Vanya and GCD 40
              • 3. Adjacent Bit Counts 80
              • 4. Roy and Coin Boxes 80
              • 5. Jon Snow and his favourite number 80
              • 6. Alyona and Spreadsheet 80
              • 7. Angry Children 80
          • 2. Practice Problems
            • Assignment 1
              • 1. LCS Problem 80
              • 2. Edit Distance Problem 80
              • 3. Balika Vadhu Problem 120
              • 4. Knapsnack Problem 120
              • 5. PARTY Problem 80
              • 6. Subset Sum Problem 40
            • Assignment 2
              • 1. Miser Man 40
              • 2. Trader Profit 80
              • 3. Charlie and Pilots 80
              • 4. Square Brackets 80
              • 5. Distinct Subsequences 120
              • 6. Smallest Super Sequence 80
              • 7. Shortest Subsequence 80
          • 3. DP & Bitmasking
            • 0 index
            • 1. What is bitmasking
            • 2. More about Bitmasking
            • 3. Dynamic Programming with Bitmasking
            • 4. Code Memoization and Recursion
              • 0 index
        • 7. Greedy Method
          • 1. Introduction to Greedy technique
            • 0 index
          • 2. Minimum Absolute difference in an array
          • Assignment 1
            • 1. Min. Absolute Difference In Array 40
            • 2. Nikunj and Donuts 40
            • 3. Activity Selection 80
            • 4. Fractional Knapsack 40
            • 5. Weighted Job Scheduling 80
          • Assignment 2
            • 1. Perimeter with conditions 40
            • 2. Problem discussion 40
            • 3. Winning Lottery 40
        • 8. GraphsX
          • 1. Connected Components
          • 2. Permutation Swaps
          • 3. Connected Horses
          • 4. Strongly connected components
          • 5. Bottom of the graph
          • 6. Bipartite Graph
          • 7. Fill Matrix
        • 9. String Algorithms
          • 1. Pattern Matching Basics
          • 2. KMP algorithm
            • 0 index
          • 3. Z algorithm for pattern matching
        • Home
          • 0 index
          • 3. Resources
          • cpbook.net
        • notebook
      • The Algorithm Design Manual Skiena
        • Introduction to Algorithm Design
          • Robot Tour Optimization
          • Exercises
          • Selecting the right jobs
          • Reasoning about Correctness
          • Induction And Recursion
          • Modeling the Problem
          • Proof by Contradiction
          • About the War Stories
          • War Story Psychic Modeling
          • Estimation
        • Algorithm Analysis
          • RAM model of computation
          • Advanced Analysis
          • Big Oh notation
          • Growth rates and dominance relations
          • Working with Big Oh
          • Reasoning about efficiency
          • Summations
          • Logarithms and their applications
          • Properties of Logarithms
          • War Story Mystery of the Pyramids
      • CLRS
        • Foundations
          • The Role of Algorithms in Computing
          • Getting Started
          • Growth of Functions
          • Divide and Conquer
            • Math assumptions
            • Recurrence equations
          • Probabilistic Analysis and Randomized Algorithms
        • Sorting and Order Statistics
          • Heapsort
          • Quicksort
          • Sorting in Linear Time
          • Medians and Order Statistics
        • Data Structures
          • Elementary Data Structures
          • Hash Tables
          • Binary Search Trees
          • Red Black Trees
          • Augmenting Data Structures
        • Advanced Design and Analysis Techniques
          • Dynamic Programming
          • Greedy Algorithms
          • Amortized Analysis
        • Advanced Data Structures
          • B Trees
          • Fibonacci Heaps
          • van Emde Boas Trees
          • Data Structures for Disjoint Sets
        • Graph Algorithms
          • Elementary Graph Algorithms
          • Minimum Spanning Trees
          • Single Source Shortest Paths
          • All Pairs Shortest Paths
          • Maximum Flow
        • Selected Topics
          • Multithreaded Algorithms
          • Matrix Operations
          • Linear Programming
          • Polynomials and the FFT
          • Number Theoretic Algorithms
          • String Matching
          • Computational Geometry
          • NP Completeness
          • Approximation Algorithms
      • Scaler Paid
        • Onboarding
          • Meet and Greet
          • 1 Growth path UI fullstack
          • Growth path senior BE
          • Problem Solving Mindset
        • DSA
          • Time Complexity
          • Array techniques
          • Arrays 1D
          • Arrays 2D
        • HLD
          • HLD Basics and Consistent Hashing
          • Consistent Hashing
          • Caching
          • Caching continued 1
          • Caching continued 2
          • CAP Theorem
        • Course timeline
        • Guest Talks
          • Guest Talk 1
    • 5 projects
    • 6 setup
  • tooling
    • README
    • obsidian templates
      • README
      • templater
        • timestamp
        • title and date
        • w2h
  • vault
    • Algorithms
      • Searching
      • Merging
      • Sorting
      • Divide n Conquer
    • Data Structures
      • String
    • STL
      • Containers
      • Algorithms