500+ Data Structures and Algorithms Interview Questions & Practice Problems
Array Find pair with given sum in the array Check if subarray with 0 sum is exists or not Print all sub-arrays with 0 sum Sort binary array in linear time Find a duplicate element in a limited range array Find maximum length sub-array having given sum Find maximum length sub-array having equal number of 0’s and 1’s Find maximum product of two integers in an array Sort an array containing 0’s, 1’s and 2’s (Dutch National Flag Problem) In place merge two sorted arrays Merge two arrays by satisfying given constraints Find index of 0 to replace to get maximum length sequence of continuous ones Shuffle a given array of elements (Fisher–Yates shuffle) Rearrange the array with alternate high and low elements Find equilibrium index of an array Find largest sub-array formed by consecutive integers Find majority element (Boyer–Moore Majority Vote Algorithm) Move all zeros present in the array to the end Replace each element of array with product of every other element without using / operator Find Longest Bitonic Subarray in an array Longest Increasing Subsequence Find maximum difference between two elements in the array by satisfying given constraints Maximum Sum Subarray Problem (Kadane’s Algorithm) Print continuous subarray with maximum sum Maximum Sum Circular Subarray Find all distinct combinations of given length — I Find all distinct combinations of given length with repetition allowed Find maximum sequence of continuous 1’s formed by replacing at-most k zeroes by ones Find minimum sum subarray of given size k Find maximum product subarray in a given array Find subarray having given sum in given array of integers Find the length of smallest subarray whose sum of elements is greater than the given number Find largest number possible from set of given numbers Find the smallest window in array sorting which will make the entire array sorted Find maximum sum path involving elements of given arrays Maximum profit earned by buying and selling shares any number of times Trapping Rain Water within given set of bars Find minimum platforms needed in the station so to avoid any delay in arrival of any train Decode the array constructed from another array Sort an array using one swap Find Triplet with given sum in an array Length of longest continuous sequence with same sum in given binary arrays Reverse every consecutive m elements of the given subarray Maximum Product Subset Problem Find pairs with given difference k in the array Find pairs with given difference k in the array | Constant space solution 4 sum problem | Quadruplets with given sum Print all quadruplets with given sum | 4-sum problem extended Quickselect Algorithm Rearrange array such that A[A[i]] is set to i for every element A[i] Print all Triplets that forms Arithmetic Progression Print all Triplets that forms Geometric Progression Print all combination of numbers from 1 to n having sum n Replace each element of the array by its corresponding rank in the array Print all Triplets in an array with sum less than or equal to given number Group elements of an array based on their first occurrence Find minimum difference between index of two given elements present in the array Find maximum absolute difference between sum of two non-overlapping sub-arrays Find all Symmetric Pairs in an Array of Pairs Partition an array into two sub-arrays with the same sum Find count of distinct elements in every sub-array of size k Find two numbers with maximum sum formed by array digits Print all sub-arrays of an array having distinct elements Find a Triplet having Maximum Product in an Array Find Minimum Index of Repeating Element in an Array Generate random input from an array according to given probabilities Find pair in an array having minimum absolute sum Find Index of Maximum Occurring Element with Equal Probability Check if an Array is Formed by Consecutive Integers Find two non-overlapping pairs having same sum in an array Add elements of two arrays into a new array Find Minimum Product among all Combinations of Triplets in an Array Replace every element of an array with the least greater element on its right Find all odd occurring elements in an array having limited range of elements Count the distinct absolute values in the sorted array Print all combinations of positive integers in increasing order that sum to a given number Find all distinct combinations of given length — II Find subarrays with given sum in an array Find the surpasser count for each element of an array Find maximum length sequence of continuous ones (Using Sliding Window) Find maximum length sequence of continuous ones Find index that divides an array into two non-empty subarrays of equal sum Calculate frequency of all elements present in an array of specified range Rearrange the array such that it contains positive and negative numbers at alternate positions Find a sorted triplet in the given array Shuffle an array according to the given order of elements Count number of strictly increasing sub-arrays in an array Find duplicates within given range k in an array Longest Alternating Subarray Problem Find minimum range with at-least one element from each of the given arrays Find longest subsequence formed by consecutive integers Find all elements in an array that are greater than all elements present to their right Find missing number in array without using extra space Determine index of an element in given array which satisfies given constraints Find minimum moves required for converting a given array to an array of zeroes Left rotate an array Right rotate an array k times Find maximum profit earned from at most two stock transactions Find Frequency of each element in a sorted array containing duplicates Find Minimum and Maximum element in an array using minimum comparisons Difference between Subarray, Subsequence and Subset Find odd occurring element in an array in single traversal Find odd occurring element in logarithmic time Find two odd occurring elements in an array without using any extra space Check if given array represents min heap or not Find K’th smallest element in an array Find K’th largest element in an array Sort a K-Sorted Array Merge M sorted lists of variable length Find smallest range with at-least one element from each of the given lists Merge M sorted lists each containing N elements Find maximum sum of subsequence with no adjacent elements Find ways to calculate a target from elements of specified array Sort elements by their frequency and Index Sort an array based on order defined by another array Inversion Count of an array Segregate positive and negative integers in linear time Find number of rotations in a circularly sorted array Search an element in a circular sorted array Find first or last occurrence of a given number in a sorted array Count occurrences of a number in a sorted array with duplicates Find smallest missing element from a sorted array Find Floor and Ceil of a number in a sorted array Search in a nearly sorted array in logarithmic time Find number of 1’s in a sorted binary array Find Missing Term in a Sequence in Logarithmic time Find missing number and duplicate elements in an array Find the peak element in an array Find Floor and Ceil of a number in a sorted array (Recursive solution) Print all distinct subsets of a given set Find two duplicate elements in a limited range array (using XOR) Combinations of words formed by replacing given numbers with corresponding alphabets 0–1 Knapsack Problem Subset sum Problem Partition Problem 3-Partition Problem 3-partition problem extended | Print all partitions K-Partition Problem | Printing all Partitions Minimum Sum Partition Problem Rod Cutting Longest Alternating Subsequence Problem Coin change-making problem (unlimited supply of coins) Coin Change Problem — Find total number of ways to get the denomination of coins Find maximum profit earned from at most K stock transactions Backtracking Print all possible solutions to N Queens Problem Print all Possible Knight’s Tours in a chessboard Find Shortest Path in Maze Find Longest Possible Route in a Matrix Find path from source to destination in a matrix that satisfies given constraints Find total number of unique paths in a maze from source to destination Print All Hamiltonian Path present in a graph Print all k-colorable configurations of the graph (Vertex coloring of graph) Find all Permutations of a given string All combinations of elements satisfying given constraints Find all binary strings that can be formed from given wildcard pattern K-Partition Problem | Printing all Partitions Magnet Puzzle Find ways to calculate a target from elements of specified array Find minimum number possible by doing at-most K swaps Determine if a pattern matches with a string or not Generate list of possible words from a character matrix Find the path between given vertices in a directed graph Find all Possible Topological Orderings of a DAG Print all shortest routes in a rectangular grid Binary Bit Hacks — Part 1 (Basic) Bit Hacks — Part 2 (Playing with k’th bit) Bit Hacks — Part 3 (Playing with rightmost set bit of a number) Bit Hacks — Part 4 (Playing with letters of English alphabet) Bit Hacks — Part 5 (Find absolute value of an integer without branching) Bit Hacks — Part 6 (Random Problems) Brian Kernighan’s Algorithm to count set bits in an integer Round up to the next highest power of 2 Round up to the previous power of 2 Compute parity of a number using lookup table Count set bits using lookup table Find the minimum or maximum of two integers without using branching Multiply 16-bit integers using 8-bit multiplier Swap individual bits at given position in an integer Check if given number is power of 4 or not Check if given number is power of 8 or not Reverse Bits of a given Integer Find odd occurring element in an array in single traversal Find two odd occurring elements in an array without using any extra space Swap two bits at given position in an integer Add binary representation of two integers Swap Adjacent Bits of a Number Print all distinct subsets of a given set Perform Division of two numbers without using division operator (/) Check if adjacent bits are set in binary representation of a given number Conditionally negate a value without branching Find two duplicate elements in a limited range array (using XOR) Reverse Bits of an integer using lookup table Find missing number and duplicate elements in an array Circular shift on binary representation of an integer by k positions Compute modulus division without division and modulo operator Solve given set of problems without using multiplication or division operators Find XOR of two numbers without using XOR operator Generate power set of a given set Huffman Coding Find missing number in array without using extra space Find odd occurring element in logarithmic time Find all odd occurring elements in an array having limited range of elements Binary Tree Check if two given binary trees are identical or not Calculate height of a binary tree Delete given Binary Tree Inorder Tree Traversal (Iterative & Recursive Implementation) Preorder Tree Traversal (Iterative & Recursive Implementation) Postorder Tree Traversal (Iterative & Recursive Implementation) 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 In-place convert given binary tree to its sum tree Determine if given two nodes are cousins of each other Print cousins of given node in a binary tree Check if given binary tree is a sum tree or not Combinations of words formed by replacing given numbers with corresponding alphabets Determine if given binary tree is a subtree of another binary tree or not Find diameter of a binary tree Check if given binary Tree has symmetric structure or not Convert binary tree to its mirror Check if binary tree can be converted to another by doing any no. of swaps of left & right child Find Lowest Common Ancestor (LCA) of two nodes in a binary tree Print all paths from root to leaf nodes in a binary tree Find ancestors of given node in a Binary Tree Find the distance between given pairs of nodes in a binary tree Find Vertical Sum in a given Binary Tree Perform vertical traversal of a binary tree — I Perform vertical traversal of a binary tree — II Print corner nodes of every level in binary tree Find the diagonal sum of given binary tree Print Diagonal Traversal of Binary Tree In-place convert Binary Tree to Doubly Linked List Sink nodes containing zero to the bottom of the binary tree Convert given binary tree to full tree by removing half nodes Truncate given binary tree to remove nodes which lie on a path having sum less than K Find maximum sum root-to-leaf path in a binary tree Check if given binary tree is height balanced or not Find maximum width of given binary tree Convert normal binary tree to Left-child right-sibling binary tree Determine if given Binary Tree is a BST or not Convert a Binary Tree to BST by maintaining its original structure Invert a Binary Tree Print Right View of a Binary Tree Print all paths from leaf to root node in given binary tree Iteratively print leaf to root path for every leaf node in a binary tree Build Binary Tree from given Parent array Find all nodes at given distance from leaf nodes in a binary tree Count all subtrees having same value of nodes in a binary tree Find Maximum Difference Between a Node and its Descendants in a Binary Tree Construct a Binary Tree from Ancestor Matrix Calculate height of a binary tree with leaf nodes forming a circular doubly linked list Find maximum sum path between two leaves in a binary tree Fix a binary tree that is only one swap away from becoming a BST Construct a binary tree from inorder and preorder traversal Construct a binary tree from inorder and postorder traversals Construct a binary tree from inorder and level order sequence Construct a full binary tree from preorder sequence with leaf node information Construct a full binary tree from a preorder and postorder sequence Set next pointer to inorder successor of all nodes in binary tree Efficiently print all nodes between two given levels in a binary tree Find preorder traversal of a binary tree from its inorder and postorder sequence Find the difference between sum of all nodes present at odd and even levels in a binary tree Find the size of the largest BST in a Binary Tree Link nodes present in each level of a binary tree in the form of a linked list Construct a Cartesian Tree from In-order Traversal Implementation of Treap Data Structure (Insert, Search and Delete) Clone a binary tree with random pointers Threaded Binary Tree: Overview and Implementation Invert alternate levels of a perfect binary tree Convert a Binary Tree into a Doubly Linked List in Spiral Order Check if a binary tree is a min-heap or not Determine if a binary tree satisfy the height-balanced property of red–black tree Depth first search (DFS) vs Breadth first search (BFS) BST Insertion in BST Search given key in BST Deletion from BST Construct balanced BST from given keys Determine if given Binary Tree is a BST or not Check if given keys represents same BSTs or not without building the BST Find inorder predecessor for given key in a BST Find Lowest Common Ancestor (LCA) of two nodes in a Binary Search Tree Find K’th smallest and K’th largest element in BST Floor and Ceil in a Binary Search Tree Find optimal cost to construct binary search tree Convert a Binary Tree to BST by maintaining its original structure Remove nodes from BST that have keys outside the valid range Find a pair with given sum in a BST Find inorder successor for given key in a BST Replace every element of an array with the least greater element on its right Fix a binary tree that is only one swap away from becoming a BST Update every key in BST to contain sum of all greater keys Check if a given sequence represents preorder traversal of a BST Build a Binary Search Tree from a Postorder Sequence Build a Binary Search Tree from a Preorder Sequence Find a triplet with given sum in a BST Count subtrees in a BST whose nodes lies within a given range Merge two BSTs into a doubly linked list in sorted order Construct a height-balanced BST from an unbalanced BST Find the size of the largest BST in a Binary Tree Convert a Binary Search Tree into a Min Heap Construct a Height-Balanced BST from a Sorted Doubly Linked List Divide & Conquer Binary Search Algorithm Find number of rotations in a circularly sorted array Search an element in a circular sorted array Find first or last occurrence of a given number in a sorted array Count occurrences of a number in a sorted array with duplicates Find smallest missing element from a sorted array Find Floor and Ceil of a number in a sorted array Search in a nearly sorted array in logarithmic time Find number of 1’s in a sorted binary array Find the peak element in an array Maximum Sum Subarray using Divide & Conquer Efficiently implement a power function Find Missing Term in a Sequence in Logarithmic time Division of Two Numbers using Binary Search Algorithm Find Floor and Ceil of a number in a sorted array (Recursive solution) Find Frequency of each element in a sorted array containing duplicates Find odd occurring element in logarithmic time Ternary Search vs Binary search Exponential search Unbounded Binary Search Interpolation search Merge Sort Algorithm QuickSort Algorithm Dynamic Programming Introduction to Dynamic Programming Longest Common Subsequence Problem Longest Common Subsequence | Space optimized version Longest Common Subsequence of K-sequences Longest Common Subsequence | Finding all LCS Longest Common Substring Problem Longest Palindromic Subsequence Problem Longest Repeated Subsequence Problem Implement Diff Utility Shortest Common Supersequence Problem Shortest Common Supersequence | Finding all SCS Shortest Common Supersequence Problem using LCS Longest Increasing Subsequence Problem Longest Decreasing Subsequence Problem Longest Bitonic Subsequence Increasing Subsequence with Maximum Sum The Levenshtein Distance (Edit Distance) Problem Find size of largest square sub-matrix of 1’s present in given binary matrix Matrix Chain Multiplication Find the minimum cost to reach last cell of the matrix from its first cell Find longest sequence formed by adjacent numbers in the matrix Count number of paths in a matrix with given cost to reach destination cell 0–1 Knapsack Problem Maximize value of the expression Partition Problem Subset sum Problem 3-Partition Problem Minimum Sum Partition Problem Rod Cutting Maximum Product Rod Cutting Coin change-making problem (unlimited supply of coins) Coin Change Problem — Find total number of ways to get the denomination of coins Total possible solutions to linear equation of k variables Longest Alternating Subsequence Problem Count number of times a pattern appears in given string as a subsequence Collect maximum points in a matrix by satisfying given constraints Find all N-digit binary strings without any consecutive 1’s Count total possible combinations of N-digit numbers in a mobile keypad Word Break Problem Determine Minimal Adjustment Cost of an Array Check if a string is K-Palindrome or not Find total ways to achieve given sum with n throws of dice having k faces Wildcard Pattern Matching Find number of ways to fill a N x 4 matrix with 1 x 4 tiles Ways to reach the bottom-right corner of a matrix with exactly k turns allowed Weighted Interval Scheduling Problem Box Stacking Problem Find total ways to reach the n’th stair with at-most m steps Find total ways to reach the n’th stair from the bottom Activity Selection Problem Find minimum number of deletions required to convert a string into palindrome Calculate minimum cost to reach destination city from source city Pots of Gold Game Problem Find minimum cuts needed for palindromic partition of a string Weighted Interval Scheduling using LIS algorithm Find minimum jumps required to reach the destination Find probability that a person is alive after taking N steps on the island Find maximum sum of subsequence with no adjacent elements Maximum Length Snake Sequence Calculate size of the largest plus of 1’s in binary matrix Longest Increasing Subsequence using LCS Find maximum profit earned from at most K stock transactions Count all paths in a matrix from first cell to last cell Check if a string matches with a given wildcard pattern Check if given string is interleaving of two other given strings Find all employees who directly or indirectly reports to a manager Find optimal cost to construct binary search tree Find maximum sum of subsequence with no adjacent elements Maximum Sum Subarray Problem (Kadane’s Algorithm) Longest Alternating Subarray Problem Collect maximum value of coins in a matrix Find length of longest path in the matrix with consecutive characters Find ways to calculate a target from elements of specified array Calculate sum of all elements in a sub-matrix in constant time Find maximum sum K x K sub-matrix in a given M x N matrix Find maximum sum submatrix present in a given matrix Single-Source Shortest Paths — Bellman Ford Algorithm All-Pairs Shortest Paths — Floyd Warshall Algorithm Graph Terminology and Representations of Graphs Graph Implementation — C, C++, C++ (STL), Java (Collections), Python Breadth First Search (BFS) Algorithm Depth First Search (DFS) Algorithm Depth first search (DFS) vs Breadth first search (BFS) Arrival and Departure Time of Vertices in DFS Types of edges involved in DFS and relation between them Bipartite Graph Determine if a given graph is Bipartite Graph using DFS Snake and Ladder Problem Topological Sorting in a DAG Kahn’s Topological Sort Algorithm Transitive Closure of a Graph Check if an undirected graph contains cycle or not Total paths in given digraph from given source to destination having exactly m edges Determine if an undirected graph is a Tree (Acyclic Connected Graph) 2-Edge Connectivity in the graph 2-Vertex Connectivity in the graph Check if given digraph is a DAG (Directed Acyclic Graph) or not Disjoint-Set Data Structure (Union-Find Algorithm) Chess Knight Problem — Find Shortest path from source to destination Check if given Graph is Strongly Connected or not Check if given Graph is Strongly Connected or not using one DFS Traversal Union-Find Algorithm for Cycle Detection in undirected graph Kruskal’s Algorithm for finding Minimum Spanning Tree Single-Source Shortest Paths — Dijkstra’s Algorithm Single-Source Shortest Paths — Bellman Ford Algorithm All-Pairs Shortest Paths — Floyd Warshall Algorithm Find Cost of Shortest Path in DAG using one pass of Bellman-Ford Least Cost Path in Weighted Digraph using BFS Find maximum cost path in graph from given source to destination Determine negative-weight cycle in a graph Least cost path in given digraph from given source to destination having exactly m edges Find the path between given vertices in a directed graph Find all Possible Topological Orderings of a DAG Find the correct order of alphabets in a given dictionary of ancient origin Find longest path in a Directed Acyclic Graph (DAG) Construct a directed graph from undirected graph that satisfies given constraints Print all k-colorable configurations of the graph (Vertex coloring of graph) Print All Hamiltonian Path present in a graph Graph Coloring Problem Greedy Activity Selection Problem Huffman Coding Job Sequencing Problem with Deadlines Graph Coloring Problem Kruskal’s Algorithm for finding Minimum Spanning Tree Single-Source Shortest Paths — Dijkstra’s Algorithm Shortest Superstring Problem Heap Introduction to Priority Queues using Binary Heaps Min Heap and Max Heap Implementation — C++, Java Heap Sort Algorithm Check if given array represents min heap or not Convert Max Heap to Min Heap in linear time Find K’th largest element in an array Sort a K-Sorted Array Merge M sorted lists of variable length Merge K sorted linked lists Find K’th smallest element in an array Find smallest range with at-least one element from each of the given lists Merge M sorted lists each containing N elements Find first k non-repeating characters in a string in single traversal Find first k maximum occurring words in given set of strings Implementation of Treap Data Structure (Insert, Search and Delete) Convert a Binary Search Tree into a Min Heap Check if a binary tree is a min-heap or not Huffman Coding External Merge Sort Algorithm Linked List Introduction to Linked Lists Linked List Implementation — C, C++, Java, Python Linked List | Insertion at Tail Static Linked List Clone given Linked List Delete Linked List Pop operation in linked list Insert given node into the correct sorted position in the given sorted linked list Rearrange linked list in increasing order (Sort linked list) Split the nodes of the given linked list into front and back halves Remove duplicates from a sorted linked list Move front node of the given list to the front of the another list Move even nodes to the end of the list in reverse order Split given linked list into two lists where each list containing alternating elements from it Construct a linked list by merging alternate nodes of two given lists Merge Sort Algorithm for Singly Linked List Merge two sorted linked lists into one Merge K sorted linked lists Intersection of two given sorted linked lists Reverse Linked List (Iterative Solution) Reverse Linked List (Recursive Solution) Reverse every group of k nodes in given linked list Find K’th node from the end in a linked list Merge alternate nodes of two linked lists into the first list Merge two sorted linked lists from their end Delete every N nodes in a linked list after skipping M nodes Rearrange linked list in specific manner in linear time Check if linked list is palindrome or not Move last node to front in a given Linked List Rearrange the linked list in specific manner Detect Cycle in a linked list (Floyd’s Cycle Detection Algorithm) Sort linked list containing 0’s, 1’s and 2’s Implement Stack using Linked List Implement Queue using Linked List Remove duplicates from a linked list Rearrange the linked list so that it has alternating high, low values Rearrange a Linked List by Separating Odd Nodes from the Even Ones Calculate height of a binary tree with leaf nodes forming a circular doubly linked list XOR Linked List: Overview and Implementation Convert a multilevel linked list to a singly linked list Recursively check if linked list of characters is palindrome or not Merge two BSTs into a doubly linked list in sorted order Remove redundant nodes from a path formed by a linked list Add a single-digit number to a linked list representing a number Reverse every alternate group of k nodes in a linked list Determine if a given linked list is a palindrome or not Sort a Doubly Linked List using Merge Sort Reverse a Doubly Linked List Pairwise swap adjacent nodes of a linked list Flatten a linked list Check if a Linked List of String is Palindromic Flatten a multilevel linked list Construct a height-balanced BST from an unbalanced BST Swap K’th node from beginning with K’th node from end in a Linked List Add two linked lists without using any extra space Clone a Linked List with Random Pointers Update random pointer for each linked list node to point to the maximum node Link nodes present in each level of a binary tree in the form of a linked list Convert a Ternary Tree to a Doubly Linked List Print nodes of a given binary tree in vertical order Convert a Binary Tree into a Doubly Linked List in Spiral Order Construct a Height-Balanced BST from a Sorted Doubly Linked List In-place merge two sorted linked lists without modifying links of the first list Reverse specified portion of a Linked List Matrix Print Matrix in Spiral Order Create Spiral Matrix from given array Shift all matrix elements by 1 in Spiral Order Find Shortest path from source to destination in a matrix that satisfies given constraints Change all elements of row i and column j in a matrix to 0 if cell (i, j) has value 0 Print diagonal elements of the matrix having positive slope Find all paths from first cell to last cell of a matrix Replace all occurrences of 0 that are not surrounded by 1 in a binary matrix In-place rotate the matrix by 90 degrees in clock-wise direction Count negative elements present in sorted matrix in linear time Report all occurrences of an element in row wise and column wise sorted matrix in linear time Calculate sum of all elements in a sub-matrix in constant time Find maximum sum K x K sub-matrix in a given M x N matrix Find maximum sum submatrix present in a given matrix Count the number of islands Flood Fill Algorithm Find shortest safe route in a field with sensors present Find all occurrences of given string in a character matrix Shortest path in a Maze | Lee Algorithm Check if given matrix is Toeplitz matrix or not In-place rotate the matrix by 180 degrees Fill Binary Matrix with Alternating Rectangles of 0 and 1 Find all common elements present in every row of given matrix Construct a Binary Tree from Ancestor Matrix Find common elements present in all rows of a matrix Find index of the row containing maximum number of 1’s in a binary matrix Find the largest square sub-matrix which is surrounded by all 1's Find minimum passes required to convert all negative values in the matrix Print a spiral square matrix without using any extra space Print all shortest routes in a rectangular grid Find length of longest path in the matrix with consecutive characters Collect maximum value of coins in a matrix Young Tableau | Insert, Search, Extract-Min, Delete, Replace Sort an array using Young tableau Find path from source to destination in a matrix that satisfies given constraints Generate list of possible words from a character matrix Find probability that a person is alive after taking N steps on the island Collect maximum points in a matrix by satisfying given constraints Count number of paths in a matrix with given cost to reach destination cell Find longest sequence formed by adjacent numbers in the matrix Find the minimum cost to reach last cell of the matrix from its first cell Ways to reach the bottom-right corner of a matrix with exactly k turns allowed Matrix Chain Multiplication Find size of largest square sub-matrix of 1’s present in given binary matrix Chess Knight Problem — Find Shortest path from source to destination Find Duplicate rows in a binary matrix Print all possible solutions to N Queens Problem Print all Possible Knight’s Tours in a chessboard Find Shortest Path in Maze Find Longest Possible Route in a Matrix Find total number of unique paths in a maze from source to destination Calculate size of the largest plus of 1’s in binary matrix Find the maximum value of M[c][d] — M[a][b] over all choices of indexes Find shortest distance of every cell from landmine in a Maze Find shortest route in a device to construct the given string Calculate minimum cost to reach destination city from source city Count all paths in a matrix from first cell to last cell Merge M sorted lists each containing N elements Travelling Salesman Problem using Branch and Bound Puzzles Clock Angle Problem — Find angle between hour and minute hand Add two numbers without using addition operator Generate power set of a given set Implement power function without using multiplication and division operators Print all numbers between 1 to N without using semicolon Swap two numbers without using third variable Determine the if condition to print specific output Find maximum & minimum of triplet without using conditional statement and ternary operator Find numbers represented as sum of two cubes for two different pairs Print “Hello World” with empty main() function Tower of Hanoi Problem Print all numbers between 1 to N without using any loop Print a semicolon without using semicolon anywhere in the program Multiply two numbers without using multiplication operator or loops Find square of a number without using multiplication and division operator Find if a number is even or odd without using any conditional statement Set both elements of a binary array to 0 in single line Find minimum number without using conditional statement or ternary operator Perform Division of two numbers without using division operator (/) Generate 0 and 1 with 75% and 25% Probability Generate Desired Random Numbers With Equal Probability Return 0, 1 and 2 with equal Probability using the specified function Generate Fair Results from a Biased Coin Generate numbers from 1 to 7 with equal probability using specified function Implement Ternary Operator Without Using Conditional Expressions Determine if two integers are equal without using comparison and arithmetic operators Return 0 and 1 with equal Probability using the specified function Generate random input from an array according to given probabilities Compute modulus division without division and modulo operator Queue Queue Implementation using Array/List — C, C++, Java, Python Queue Implementation using Linked List Implement Stack using Queue Data Structure Implement a Queue using Stack Data Structure Efficiently print all nodes between two given levels in a binary tree Chess Knight Problem — Find Shortest path from source to destination Shortest path in a Maze | Lee Algorithm Find shortest safe route in a field with sensors present Flood Fill Algorithm Count the number of islands Find Shortest path from source to destination in a matrix that satisfies given constraints Generate binary numbers between 1 to N Calculate height of a binary tree Delete given Binary Tree 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 Find next node in same level for given node in a binary tree Check if given binary tree is complete binary tree or not Print Diagonal Traversal of Binary Tree Print corner nodes of every level in binary tree Invert a Binary Tree Find minimum passes required to convert all negative values in the matrix Convert a Binary Tree into a Doubly Linked List in Spiral Order Check if a binary tree is a min-heap or not Invert alternate levels of a perfect binary tree Convert a Binary Search Tree into a Min Heap Snake and Ladder Problem Find shortest distance of every cell from landmine in a Maze Convert a multilevel linked list to a singly linked list Breadth First Search (BFS) Algorithm Check if an undirected graph contains cycle or not Find maximum cost path in graph from given source to destination Total paths in given digraph from given source to destination having exactly m edges Least cost path in given digraph from given source to destination having exactly m edges Sorting Insertion Sort Algorithm Selection Sort Algorithm Bubble Sort Algorithm Merge Sort Algorithm Iterative Merge Sort Algorithm (Bottom-up Merge Sort) QuickSort Algorithm Iterative Implementation of QuickSort Hybrid QuickSort QuickSort using Dutch National Flag Algorithm QuickSort using Hoare’s Partitioning scheme Heap Sort Algorithm Introsort Algorithm External Merge Sort Algorithm Counting Sort Algorithm Inversion Count of an array Sort an array using Young tableau Merge Sort Algorithm for Singly Linked List Problems solved using partitioning logic of QuickSort Sort a Doubly Linked List using Merge Sort Sort elements by their frequency and Index Sort an array based on order defined by another array Efficiently sort an array with many duplicated values Find largest number possible from set of given numbers Find the surpasser count for each element of an array Segregate positive and negative integers using Merge Sort Group anagrams together from given list of words Stack Stack Implementation using Array/List — C, C++, Java, Python Stack Implementation using Linked List Check if given expression is balanced expression or not Find duplicate parenthesis in an expression Evaluate given postfix expression Decode the given sequence to construct minimum number without repeated digits Design a stack which returns minimum element in constant time Design a stack which returns minimum element without using auxiliary stack Merging Overlapping Intervals Reverse String without using Recursion Implement Stack using Queue Data Structure Implement a Queue using Stack Data Structure Implement two stacks in a single array Recursive solution to sort a stack Find length of the longest balanced parenthesis in a string Reverse a string using stack data structure Find all elements in an array that are greater than all elements present to their right Inorder Tree Traversal Preorder Tree Traversal Postorder Tree Traversal Find preorder traversal of a binary tree from its inorder and postorder sequence Find ancestors of given node in a Binary Tree Check if two given binary trees are identical or not Reverse Level Order Traversal of Binary Tree Reverse given text without reversing the individual words Find all binary strings that can be formed from given wildcard pattern Iterative Implementation of QuickSort Depth First Search (DFS) Algorithm Invert a Binary Tree Print leaf to root path for every leaf node in a binary tree Longest Increasing Subsequence Invert alternate levels of a perfect binary tree String Check if given string is a rotated palindrome or not Longest Palindromic Substring (Non-DP Space Optimized Solution) Check if repeated subsequence is present in the string or not Check if strings can be derived from each other by circularly rotating them Check if given set of moves is circular or not Convert given number into corresponding excel column name Determine if two strings are anagram or not Find all binary strings that can be formed from given wildcard pattern Find all interleaving 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 possible 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 Group anagrams together from given list of words Find minimum operations required to transform a string into another string Determine if a string can be transformed into another string with a single edit Find length of the longest balanced parenthesis in a string In place remove all occurrences of ‘AB’ and ‘C’ from the string Longest even length palindromic sum substring Print string in zig-zag form in k rows Reverse given text without reversing the individual words Run Length Encoding (RLE) Data Compression Algorithm 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 Find the longest substring of given string containing all distinct characters Iterative Approach to find Permutations of a String Generate all Permutations of a String in Java Find all lexicographically next permutations of a string sorted in ascending order Find Lexicographically minimal string rotation Find all strings of given length containing balanced parentheses Find all combinations of non-overlapping substrings of a string Determine if a given string is palindrome or not Find the minimum number of inversions needed to make the given expression balanced Construct the longest palindrome by shuffling or deleting characters from a string Print all combinations of phrases formed by picking words from each of the given lists Break a string into all possible combinations of non-overlapping substrings Remove all extra spaces from a string Remove adjacent duplicate characters from a string Find first non-repeating character in a string by doing only one traversal of it Find all N-digit strictly increasing numbers (Bottom-Up and Top-Down Approach) Find all N-digit binary numbers having more 1’s than 0’s for any prefix Find all N-digit numbers with given sum of digits Find all N-digit binary numbers with k-bits set where k ranges from 1 to N Find all N-digit binary numbers with equal sum of bits in its two halves Find all N-digit numbers with equal sum of digits at even and odd index Find all Lexicographic Permutations of a String Lexicographic Rank of a String Find all lexicographically previous permutations of a string sorted in descending order Replace all non-overlapping occurrences of the pattern Introduction to Pattern Matching Implementation of KMP Algorithm Reverse String without using Recursion Reverse given string using Recursion Determine if characters of a String follow a specified order or not In-place remove all adjacent duplicates from the given string Check if given sentence is syntactically correct or not Find all Permutations of a given string Find first k non-repeating characters in a string in single traversal Check if given string is interleaving of two other given strings Decode the given sequence to construct minimum number without repeated digits Combinations of words formed by replacing given numbers with corresponding alphabets Count number of times a pattern appears in given string as a subsequence Check if a string matches with a given wildcard pattern Find all words matching a pattern in the given dictionary The Levenshtein Distance (Edit Distance) Problem Longest Common Subsequence Problem Longest Repeated Subsequence Problem Longest Palindromic Subsequence using Dynamic Programming Longest Common Substring Problem Shortest Common Supersequence Problem Word Break Problem Wildcard Pattern Matching Find minimum cuts needed for palindromic partition of a string Check if a string is K-Palindrome or not Find shortest route in a device to construct the given string Find minimum number possible by doing at-most K swaps Determine if a pattern matches with a string or not Find minimum number of deletions required to convert a string into palindrome Trie Trie Implementation — C, C++, Java, Python Memory Efficient Implementation of Trie | Insert, Search and Delete Longest Common Prefix in given set of strings (using Trie) Lexicographic sorting of given set of keys Find maximum occurring word in given set of strings Find first k maximum occurring words in given set of strings Find Duplicate rows in a binary matrix Word Break Problem | Using Trie Generate list of possible words from a character matrix Find all words matching a pattern in the given dictionary