Data structures and algorithms problems in C++ using STL


Heap (Priority Queue) –


Graphs –


Array –

  • Rearrange the array with alternate high and low elements
  • Find pair with given sum in the array
  • Shuffle a given array of elements (Fisher–Yates shuffle)
  • Find equilibrium index of an array
  • Find majority element in an array (Boyer–Moore majority vote algorithm)
  • Find sub-array with 0 sum
  • Find maximum length sub-array having given sum
  • Find maximum length sub-array having equal number of 0’s and 1’s
  • Find all distinct combinations of given length
  • Find all distinct combinations of given length with repetition allowed
  • Merging Overlapping Intervals
  • Find minimum platforms needed in the station so to avoid any delay in arrival of any train
  • Longest Increasing Subsequence
  • Iterative Implementation of Quicksort
  • Custom Sort | Sort elements by their frequency and Index
  • Custom Sort | Sort elements of the array by order of elements defined by the second array
  • Find Triplet with given sum in an array
  • 4 sum problem | Quadruplets with given sum
  • Binary Search
  • Find the peak element in an array
  • Activity Selection Problem
  • Job Sequencing Problem with Deadlines

    Matrix –


    Strings –

  • Check if given string is a rotated palindrome or not
  • Check if repeated subsequence is present in the string or not
  • Check if strings can be derived from each other by circularly rotating them
  • Determine if two strings are anagram or not
  • Find all binary strings that can be formed from given wildcard pattern
  • Find all interleavings of given strings
  • Isomorphic Strings
  • Find all possible palindromic substrings in a string
  • Find all possible combinations of words formed from mobile keypad
  • Find all combinations by replacing given digits with characters of the corresponding list
  • Find all words from given list that follows same order of characters as given pattern
  • Find first k non-repeating characters in a string in single traversal
  • Group anagrams together from given list of words
  • Reverse text without reversing the individual words
  • Validate an IP address
  • Find the longest substring of given string containing k distinct characters
  • Find all palindromic permutations of a string
  • Find all substrings of a string that are permutation of a given string
  • Longest substring of given string containing distinct characters
  • Find all Permutations of a given string
  • Find all lexicographically next permutations of a string sorted in ascending order
  • Find Lexicographically minimal string rotation
  • Find all N-digit binary numbers with k-bits set where k ranges from 1 to N
  • Generate binary numbers between 1 to N
  • Calculate rank of given string among all its lexicographically sorted permutations
  • Shortest Superstring Problem

    Binary Tree –

  • Check if two binary trees are identical or not | Iterative & Recursive
  • Calculate height of binary tree | Iterative & Recursive
  • Delete given Binary Tree | Iterative & Recursive
  • Level Order Traversal of Binary Tree
  • Spiral Order Traversal of Binary Tree
  • Reverse Level Order Traversal of Binary Tree
  • Print all nodes of a given binary tree in specific order
  • Print left view of binary tree
  • Print Bottom View of Binary Tree
  • Print Top View of Binary Tree
  • Find next node in same level for given node in a binary tree
  • Check if given binary tree is complete binary tree or not
  • Determine if given binary tree is a subtree of another binary tree or not
  • Postorder Tree Traversal | Iterative & Recursive
  • Preorder Tree Traversal | Iterative & Recursive
  • Inorder Tree Traversal | Iterative & Recursive
  • Find ancestors of given node in a Binary Tree
  • Find Vertical Sum in a given Binary Tree
  • Print nodes in vertical order of a given Binary Tree (Vertical Traversal)
  • Find the diagonal sum of given binary tree
  • Print Diagonal Traversal of Binary Tree
  • Print corner nodes of every level in binary tree

    Dynamic Programming –


    Miscellaneous –



    Thank you all for your valuable time and being with us. 🙂