0% found this document useful (0 votes)
34 views26 pages

500+ Data Structures & Algorithms Problems

Uploaded by

Vũ Minh Quân
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views26 pages

500+ Data Structures & Algorithms Problems

Uploaded by

Vũ Minh Quân
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

500+ Data Structures and Algorithms practice problems

Array
[Link] pair with given sum in the array

[Link] if subarray with 0 sum is exists or not

[Link] all sub-arrays with 0 sum

[Link] binary array in linear time

[Link] a duplicate element in a limited range array

[Link] largest sub-array formed by consecutive integers

[Link] maximum length sub-array having given sum

[Link] maximum length sub-array having equal number of 0’s and 1’s

[Link] an array containing 0’s, 1’s and 2’s (Dutch national flag problem)

[Link] merge two sorted arrays

[Link] two arrays by satisfying given constraints

[Link] index of 0 to replaced to get maximum length sequence of continuous ones

[Link] maximum product of two integers in an array

[Link] a given array of elements (Fisher–Yates shuffle)

[Link] the array with alternate high and low elements

[Link] equilibrium index of an array

[Link] majority element in an array (Boyer–Moore majority vote algorithm)

[Link] all zeros present in the array to the end

[Link] each element of array with product of every other element without
using / operator

[Link] Longest Bitonic Subarray in an array

[Link] maximum difference between two elements in the array by satisfying given
constraints

[Link] subarray problem (Kadane’s algorithm)

[Link] continuous subarray with maximum sum

[Link] Sum Circular Subarray

[Link] all distinct combinations of given length

[Link] all distinct combinations of given length with repetition allowed

[Link] maximum sequence of continuous 1’s formed by replacing at-most k zeroes by


ones
[Link] minimum sum subarray of given size k

[Link] subarray having given sum in given array of integers

[Link] the length of smallest subarray whose sum of elements is greater than the
given number

[Link] largest number possible from set of given numbers

[Link] the smallest window in array sorting which will make the entire array
sorted

[Link] maximum sum path involving elements of given arrays

[Link] profit earned by buying and selling shares any number of times

[Link] Rain Water within given set of bars

[Link] Increasing Subsequence

[Link] Decreasing Subsequence Problem

[Link] maximum product subarray in a given array

[Link] maximum sum of subsequence with no adjacent elements

[Link] minimum platforms needed in the station so to avoid any delay in arrival of
any train

[Link] the array constructed from another array

[Link] an array using one swap

[Link] Triplet with given sum in an array

[Link] of longest continuous sequence with same sum in given binary arrays

[Link] array such that A[A[i]] is set to i for every element A[i]

[Link] every consecutive m elements of the given subarray

[Link] Product Subset Problem

[Link] pairs with given difference k in the array

[Link] pairs with given difference k in the array | Constant space solution

50.4 sum problem | Quadruplets with given sum

[Link] all quadruplets with given sum | 4-sum problem extended

[Link] odd occurring element in an array in single traversal

[Link] two odd occurring element in an array without using any extra space

[Link] Algorithm

[Link] all Triplets that forms Arithmetic Progression


[Link] all triplets that forms Geometric Progression

[Link] all combination of numbers from 1 to n having sum n

[Link] each element of the array by its corresponding rank in the array

[Link] all Triplets in an array with sum less than or equal to given number

[Link] elements of an array based on their first occurrence

[Link] minimum difference between index of two given elements present in the array

[Link] maximum absolute difference between sum of two non-overlapping sub-arrays

[Link] all Symmetric Pairs in an Array of Pairs

[Link] an array into two sub-arrays with the same sum

[Link] count of distinct elements in every sub-array of size k

[Link] two numbers with maximum sum formed by array digits

[Link] all sub-arrays of an array having distinct elements

[Link] a Triplet having Maximum Product in an Array

[Link] ways to calculate a target from elements of specified array

[Link] Minimum Index of Repeating Element in an Array

[Link] Random Input from an Array according to given Probabilities

[Link] pair in an array having minimum absolute sum

[Link] Index of Maximum Occurring Element with Equal Probability

[Link] if an Array is Formed by Consecutive Integers

[Link] two non-overlapping pairs having same sum in an array

[Link] Minimum Product among all Combinations of Triplets in an Array

[Link] every element of an array with the least greater element on its right

[Link] all odd occurring elements in an array having limited range of elements

[Link] elements of two arrays into a new array

[Link] the distinct absolute values in the sorted array

[Link] all combinations of positive integers in increasing order that sum to a


given number

[Link] all distinct combinations of given length — Part 2

[Link] subarrays with given sum in an array

[Link] the surpasser count for each element of an array


[Link] maximum length sequence of continuous ones (Using Sliding Window)

[Link] maximum length sequence of continuous ones

[Link] Overlapping Intervals

[Link] Selection Problem

[Link] Sequencing Problem with Deadlines

[Link] to Priority Queues using Binary Heaps

[Link] Heap and Max Heap Implementation in C++

[Link] Heap and Max Heap Implementation in Java

[Link] Sort (Out-of-place and In-place implementation in C++ and C)

[Link] if given array represents min heap or not

[Link] Max Heap to Min Heap in linear time

[Link] K’th largest element in an array

[Link] a K-Sorted Array

[Link] M sorted lists of variable length

[Link] K’th smallest element in an array

[Link] smallest range with at-least one element from each of the given lists

[Link] M sorted lists each containing N elements

[Link] sort | Iterative & Recursive

[Link] sort | Iterative & Recursive

[Link] sort | Iterative & Recursive

[Link] Sort

[Link]

[Link] Implementation of Quicksort

[Link] QuickSort

[Link] using Dutch National Flag Algorithm

[Link] Sort using Hoare’s Partitioning scheme

[Link] merge sort

[Link] Sort | Sort elements by their frequency and Index

[Link] Sort | Sort elements of the array by order of elements defined by the
second array
[Link] Count of an array

[Link] positive and negative integers in linear time

[Link] Search

[Link] Search vs Binary search

[Link] search

[Link] search

[Link] number of rotations in a circularly sorted array

[Link] an element in a circular sorted array

[Link] first or last occurrence of a given number in a sorted array

[Link] occurrences of a number in a sorted array with duplicates

[Link] smallest missing element from a sorted array

[Link] Floor and Ceil of a number in a sorted array

[Link] in a nearly sorted array in O(logn) time

[Link] number of 1’s in a sorted binary array

[Link] the peak element in an array

[Link] Sum Subarray using Divide & Conquer

[Link] Minimum and Maximum element in an array using minimum comparisons

[Link] Chain Multiplication

132.0–1 Knapsack problem

[Link] value of the expression

[Link] problem

[Link] sum problem

[Link] Sum Partition problem

[Link] Cutting

[Link] change-making problem (unlimited supply of coins)

[Link] Change Problem (Total number of ways to get the denomination of coins)

[Link] alternating subsequence

[Link] of words formed by replacing given numbers with corresponding


alphabets

[Link] the given sequence to construct minimum number without repeated digits
[Link] combinations of elements satisfying given constraints

[Link] Missing Term in a Sequence in log(n) time

[Link] all distinct Subsets of a given Set

[Link] Floor and Ceil of a number in a sorted array (Recursive solution)

[Link] both elements of a binary array to 0 in single line

148.K-Partition Problem | Printing all Partitions

149.3 Partition Problem

150.3-partition problem extended | Print all partitions

[Link] Merge Sort Algorithm (Bottom-up Merge Sort)

[Link] two duplicate elements in an limited range array (using XOR)

[Link] missing number and duplicate elements in an array

[Link] Minimum and Maximum element in an array by doing minimum comparisons

[Link] Frequency of each element in a sorted array containing duplicates

[Link] between Subarray, Subsequence and Subset

Backtracking
[Link] all possible solutions to N Queens problem

[Link] all Possible Knight’s Tours in a chessboard

[Link] Shortest Path in Maze

[Link] Longest Possible Route in a Matrix

[Link] path from source to destination in a matrix that satisfies given constraints

[Link] total number of unique paths in a maze from source to destination

[Link] All Hamiltonian Path present in a graph

[Link] all k-colorable configurations of the graph (Vertex coloring of graph)

[Link] all Permutations of a given string

[Link] combinations of elements satisfying given constraints

[Link] all binary strings that can be formed from given wildcard pattern

12.K-Partition Problem | Printing all Partitions

[Link] Puzzle

[Link] ways to calculate a target from elements of specified array

[Link] minimum number possible by doing at-most K swaps


[Link] if a pattern matches with a string or not

Binary
[Link] Hacks — Part 1 (Basic)

[Link] Hacks — Part 2 (Playing with k’th bit)

[Link] Hacks — Part 3 (Playing with rightmost set bit of a number)

[Link] Hacks — Part 4 (Playing with letters of English alphabet)

[Link] Hacks — Part 5 (Find absolute value of an integer without branching)

[Link] Hacks — Part 6 (Random Problems)

[Link] Kernighan’s Algorithm to count set bits in an integer

[Link] parity of a number using lookup table

[Link] set bits using lookup table

[Link] the minimum or maximum of two integers without using branching

[Link] 16-bit integers using 8-bit multiplier

[Link] up to the next highest power of 2

[Link] up to the previous power of 2

[Link] individual bits at given position in an integer

[Link] if given number is power of 4 or not

[Link] Bits of a given Integer

[Link] odd occurring element in an array in single traversal

[Link] two odd occurring element in an array without using any extra space

[Link] two bits at given position in an integer

[Link] binary representation of two integers

[Link] Adjacent Bits of a Number

[Link] all distinct Subsets of a given Set

[Link] Division of two numbers without using division operator (/)

[Link] if adjacent bits are set in binary representation of a given number

[Link] negate a value without branching

[Link] two duplicate elements in an limited range array (using XOR)

[Link] missing number and duplicate elements in an array

[Link] if given number is power of 8 or not


[Link] shift on binary representation of an integer by k positions

[Link] given set of problems without using multiplication or division operators

[Link] Bits of an integer using lookup table

[Link] binary numbers between 1 to N

[Link] implement power function | Recursive and Iterative

[Link] square of a number without using multiplication and division operator | 3


methods

[Link] power set of a given set

[Link] Coding

[Link] all odd occurring elements in an array having limited range of elements

Binary Tree
[Link] if two given binary trees are identical or not | Iterative & Recursive

[Link] height of a binary tree | Iterative & Recursive

[Link] given Binary Tree | Iterative & Recursive

[Link] Tree Traversal | Iterative & Recursive

[Link] Tree Traversal | Iterative & Recursive

[Link] Tree Traversal | Iterative & Recursive

[Link] Order Traversal of Binary Tree

[Link] Order Traversal of Binary Tree

[Link] Level Order Traversal of Binary Tree

[Link] all nodes of a given binary tree in specific order

[Link] left view of binary tree

[Link] Bottom View of Binary Tree

[Link] Top View of Binary Tree

[Link] next node in same level for given node in a binary tree

[Link] if given binary tree is complete binary tree or not

[Link] if given two nodes are cousins of each other

[Link] cousins of given node in a binary tree

[Link]-place convert given binary tree to its sum tree

[Link] if given binary tree is a sum tree or not

[Link] of words formed by replacing given numbers with corresponding


alphabets

[Link] if given binary tree is a subtree of another binary tree or not

[Link] diameter of a binary tree

[Link] if given binary Tree has symmetric structure or not

[Link] binary tree to its mirror

[Link] if binary tree can be converted to another by doing any no. of swaps of
left & right child

[Link] Lowest Common Ancestor (LCA) of two nodes in a binary tree

[Link] all paths from root to leaf nodes in given binary tree

[Link] ancestors of given node in a Binary Tree

[Link] the distance between given pairs of nodes in a binary tree

[Link] Vertical Sum in a given Binary Tree

[Link] nodes in vertical order of a given Binary Tree (Vertical Traversal)

[Link] the diagonal sum of given binary tree

[Link] Diagonal Traversal of Binary Tree

[Link] corner nodes of every level in binary tree

[Link]-place convert convert given Binary Tree to Doubly Linked List

[Link] nodes containing zero to the bottom of the binary tree

[Link] given binary tree to full tree by removing half nodes

[Link] given binary tree to remove nodes which lie on a path having sum less
than K

[Link] maximum sum root-to-leaf path in a binary tree

[Link] if given binary tree is height balanced or not

[Link] normal binary tree to Left-child right-sibling binary tree

[Link] if given Binary Tree is a BST or not

[Link] a Binary Tree to BST by maintaining its original structure

[Link] given Binary Tree | Recursive and Iterative solution

[Link] Right View of a Binary Tree

[Link] leaf to root path for every leaf node in a binary tree

[Link] maximum width of given binary tree

[Link] Binary Tree from given Parent array


49.C++ Program to Print Binary Tree Structure

[Link] all nodes at given distance from leaf nodes in a binary tree

[Link] all subtrees having same value of nodes in a binary tree

[Link] Maximum Difference Between a Node and its Descendants in a Binary Tree

[Link] a Binary Tree from Ancestor Matrix

[Link] height of a binary tree with leaf nodes forming a circular doubly
linked list

BST
[Link] in BST

[Link] given key in BST

[Link] from BST

[Link] balanced BST from given keys

[Link] if given Binary Tree is a BST or not

[Link] if given keys represents same BSTs or not without building the BST

[Link] inorder predecessor for given key in a BST

[Link] Lowest Common Ancestor (LCA) of two nodes in a Binary Search Tree

[Link] K’th smallest and K’th largest element in BST

[Link] and Ceil in a Binary Search Tree

[Link] optimal cost to construct binary search tree

[Link] a Binary Tree to BST by maintaining its original structure

[Link] nodes from BST that have keys outside the valid range

[Link] a pair with given sum in a BST

[Link] inorder successor for given key in a BST

[Link] every element of an array with the least greater element on its right

Divide & Conquer


[Link] Search

[Link] number of rotations in a circularly sorted array

[Link] an element in a circular sorted array

[Link] first or last occurrence of a given number in a sorted array

[Link] occurrences of a number in a sorted array with duplicates

[Link] smallest missing element from a sorted array


[Link] Floor and Ceil of a number in a sorted array

[Link] in a nearly sorted array in O(logn) time

[Link] number of 1’s in a sorted binary array

[Link] the peak element in an array

[Link] Sum Subarray using Divide & Conquer

[Link] Minimum and Maximum element in an array using minimum comparisons

[Link] implement power function | Recursive and Iterative

[Link] Missing Term in a Sequence in log(n) time

[Link] of Two Numbers using Binary Search Algorithm

[Link] Floor and Ceil of a number in a sorted array (Recursive solution)

[Link] Minimum and Maximum element in an array by doing minimum comparisons

[Link] Frequency of each element in a sorted array containing duplicates

[Link] Search vs Binary search

[Link] search

[Link] search

[Link] Sort Algorithm

[Link] Merge Sort Algorithm (Bottom-up Merge Sort)

[Link] Sort Algorithm for Singly Linked List

[Link] Count of an array

[Link] Algorithm

[Link] Implementation of Quicksort

[Link] QuickSort

[Link] using Dutch National Flag Algorithm

[Link] Sort using Hoare’s Partitioning scheme

Dynamic Programming
[Link] to Dynamic Programming

[Link] Common Subsequence | Introduction & LCS Length

[Link] Common Subsequence | Space optimized version

[Link] Common Subsequence of K-sequences

[Link] Common Subsequence | Finding all LCS


[Link] Common Substring problem

[Link] Palindromic Subsequence using Dynamic Programming

[Link] Repeated Subsequence problem

[Link] Diff Utility

[Link] Common Supersequence | Introduction & SCS Length

[Link] Common Supersequence | Finding all SCS

[Link] Common Supersequence | Using LCS

[Link] Increasing Subsequence using Dynamic Programming

[Link] Bitonic Subsequence

[Link] Subsequence with Maximum Sum

[Link] Levenshtein distance (Edit distance) problem

[Link] size of largest square sub-matrix of 1’s present in given binary matrix

[Link] Chain Multiplication

[Link] the minimum cost to reach last cell of the matrix from its first cell

[Link] longest sequence formed by adjacent numbers in the matrix

[Link] number of paths in a matrix with given cost to reach destination cell

22.0–1 Knapsack problem

[Link] value of the expression

[Link] problem

[Link] sum problem

[Link] Sum Partition problem

[Link] all N-digit binary strings without any consecutive 1’s

[Link] Cutting

[Link] Product Rod Cutting

[Link] change-making problem (unlimited supply of coins)

[Link] Change Problem — Find total number of ways to get the denomination of coins

[Link] possible solutions to linear equation of k variables

[Link] alternating subsequence

[Link] number of times a pattern appears in given string as a subsequence


[Link] maximum points in a matrix by satisfying given constraints

[Link] total possible combinations of N-digit numbers in a mobile keypad

[Link] optimal cost to construct binary search tree

[Link] Break Problem

[Link] Break Problem | Using Trie Data Structure

[Link] Minimal Adjustment Cost of an Array

[Link] if a string is K-Palindrome or not

[Link] Pattern Matching

[Link] probability that a person is alive after taking N steps on the island

[Link] sum of all elements in a sub-matrix in constant time

[Link] maximum sum K x K sub-matrix in a given M x N matrix

[Link] maximum sum submatrix present in a given matrix

[Link] maximum sum of subsequence with no adjacent elements

[Link] subarray problem (Kadane’s algorithm)

[Link]-Source Shortest Paths — Bellman Ford Algorithm

[Link]-Pairs Shortest Paths — Floyd Warshall Algorithm

[Link] Decreasing Subsequence Problem

[Link] of Gold Game using Dynamic Programming

[Link] minimum cuts needed for palindromic partition of a string

[Link] Length Snake Sequence

55.3 Partition Problem

[Link] size of the largest plus of 1’s in binary matrix

[Link] if given string is interleaving of two other given strings

[Link] Increasing Subsequence using LCS

[Link] negative-weight cycle in a graph

Graphs
[Link] and Representations of Graphs

[Link] Implementation using STL

[Link] Implementation in C++ without using STL

[Link] Graph Data Structure in C


[Link] Implementation in Java using Collections

[Link] First Search (BFS) | Iterative & Recursive Implementation

[Link] First Search (DFS) | Iterative & Recursive Implementation

[Link] and Departure Time of Vertices in DFS

[Link] of edges involved in DFS and relation between them

[Link] Graph

[Link] if a given graph is Bipartite Graph using DFS

[Link] number of throws required to win Snake and Ladder game

[Link] Sorting in a DAG

[Link]’s Topological Sort Algorithm

[Link] Closure of a Graph

[Link] if an undirected graph contains cycle or not

[Link] paths in given digraph from given source to destination having exactly m
edges

[Link] if an undirected graph is a Tree (Acyclic Connected Graph)

19.2-Edge Connectivity in the graph

20.2-Vertex Connectivity in the graph

[Link] if given digraph is a DAG (Directed Acyclic Graph) or not

[Link]-Set Data Structure (Union-Find Algorithm)

[Link] Knight Problem — Find Shortest path from source to destination

[Link] if given Graph is Strongly Connected or not

[Link] if given Graph is Strongly Connected or not using one DFS Traversal

[Link]-Find Algorithm for Cycle Detection in undirected graph

[Link]’s Algorithm for finding Minimum Spanning Tree

[Link]-Source Shortest Paths — Dijkstra’s Algorithm

[Link]-Source Shortest Paths — Bellman Ford Algorithm

[Link]-Pairs Shortest Paths — Floyd Warshall Algorithm

[Link] Cost of Shortest Path in DAG using one pass of Bellman-Ford

[Link] Cost Path in Weighted Digraph using BFS

[Link] maximum cost path in graph from given source to destination


[Link] negative-weight cycle in a graph

[Link] all k-colorable configurations of the graph (Vertex coloring of graph)

[Link] All Hamiltonian Path present in a graph

[Link] coloring of graph

Heap
[Link] to Priority Queues using Binary Heaps

[Link] Heap and Max Heap Implementation in C++

[Link] Heap and Max Heap Implementation in Java

[Link] Sort

[Link] if given array represents min heap or not

[Link] Max Heap to Min Heap in linear time

[Link] K’th largest element in an array

[Link] a K-Sorted Array

[Link] M sorted lists of variable length

[Link] K’th smallest element in an array

[Link] smallest range with at-least one element from each of the given lists

[Link] M sorted lists each containing N elements

[Link] merge sort

[Link] Coding

[Link] first k maximum occurring words in given set of strings

[Link] first k non-repeating characters in a string in single traversal

Linked List
[Link] to Linked Lists

[Link] List Implementation | Part 1

[Link] List Implementation | Part 2

[Link] Linked List in C

[Link] given Linked List

[Link] Linked List

[Link] operation in linked list

[Link] given node into the correct sorted position in the given sorted linked
list
[Link] a linked list, change it to be in sorted order

[Link] the nodes of the given linked list into front and back halves

[Link] duplicates from a sorted linked list

[Link] front node of the given list to the front of the another list

[Link] even nodes to the end of the list in reverse order

[Link] given linked list into two lists where each list containing alternating
elements from it

[Link] a linked list by merging alternate nodes of two given lists

[Link] given sorted linked lists into one

[Link] Sort Algorithm for Singly Linked List

[Link] of two given sorted linked lists

[Link] linked list | Part 1 (Iterative Solution)

[Link] linked list | Part 2 (Recursive Solution)

[Link] every group of k nodes in given linked list

[Link] K’th node from the end in a linked list

[Link] alternate nodes of two linked lists into the first list

[Link] two sorted linked lists from their end

[Link] every N nodes in a linked list after skipping M nodes

[Link] linked list in specific manner in linear time

[Link] if linked list is palindrome or not

[Link] last node to front in a given Linked List

[Link] the linked list in specific manner

[Link] Cycle in a linked list (Floyd’s Cycle Detection Algorithm)

[Link] linked list containing 0’s, 1’s and 2’s

[Link] Implementation using Linked List

[Link] Implementation using Linked List

[Link] duplicates from a linked list

[Link] the linked list so that it has alternating high, low values

[Link] a Linked List by Separating Odd Nodes from the Even Ones

[Link] height of a binary tree with leaf nodes forming a circular doubly
linked list
Matrix
[Link] Matrix in Spiral Order

[Link] Spiral Matrix from given array

[Link] all matrix elements by 1 in Spiral Order

[Link] Shortest path from source to destination in a matrix that satisfies given
constraints

[Link] all elements of row i and column j in a matrix to 0 if cell (i, j) has
value 0

[Link] diagonal elements of the matrix having positive slope

[Link] all paths from first cell to last cell of a matrix

[Link] all occurrences of 0 that are not surrounded by 1 in a binary matrix

[Link]-place rotate the matrix by 90 degrees in clock-wise direction

[Link] negative elements present in sorted matrix in linear time

[Link] all occurrences of an element in row wise and column wise sorted matrix
in linear time

[Link] sum of all elements in a sub-matrix in constant time

[Link] maximum sum K x K sub-matrix in a given M x N matrix

[Link] maximum sum submatrix present in a given matrix

[Link] probability that a person is alive after taking N steps on the island

[Link] the number of islands

[Link] fill Algorithm

[Link] shortest safe route in a field with sensors present

[Link] all occurrences of given string in a character matrix

[Link] path in a Maze | Lee algorithm

[Link] if given matrix is Toeplitz matrix or not

[Link]-place rotate the matrix by 180 degrees

[Link] Binary Matrix with Alternating Rectangles of 0 and 1

[Link] all common elements present in every row of given matrix

[Link] a Binary Tree from Ancestor Matrix

[Link] common elements present in all rows of a matrix

[Link] Salesman Problem using Branch and Bound


[Link] maximum points in a matrix by satisfying given constraints

[Link] number of paths in a matrix with given cost to reach destination cell

[Link] longest sequence formed by adjacent numbers in the matrix

[Link] the minimum cost to reach last cell of the matrix from its first cell

[Link] Chain Multiplication

[Link] size of largest square sub-matrix of 1’s present in given binary matrix

[Link] Knight Problem — Find Shortest path from source to destination

[Link] Duplicate rows in a binary matrix

[Link] all possible solutions to N Queens problem

[Link] all Possible Knight’s Tours in a chessboard

[Link] Shortest Path in Maze

[Link] Longest Possible Route in a Matrix

[Link] size of the largest plus of 1’s in binary matrix

[Link] the maximum value of M[c][d] — M[a][b] over all choices of indexes

[Link] shortest distance of every cell from landmine in a Maze

[Link] shortest route in a device to construct the given string

Queue
[Link] Implementation

[Link] Implementation using Linked List

[Link] Knight Problem — Find Shortest path from source to destination

[Link] path in a Maze | Lee algorithm

[Link] shortest safe route in a field with sensors present

[Link] fill Algorithm

[Link] the number of islands

[Link] Shortest path from source to destination in a matrix that satisfies given
constraints

[Link] binary numbers between 1 to N

[Link] height of a binary tree | Iterative & Recursive

[Link] given Binary Tree | Iterative & Recursive

[Link] Order Traversal of Binary Tree

[Link] Order Traversal of Binary Tree


[Link] Level Order Traversal of Binary Tree

[Link] all nodes of a given binary tree in specific order

[Link] left view of binary tree

[Link] next node in same level for given node in a binary tree

[Link] if given binary tree is complete binary tree or not

[Link] Diagonal Traversal of Binary Tree

[Link] corner nodes of every level in binary tree

[Link] First Search (BFS) | Iterative & Recursive Implementation

[Link] number of throws required to win Snake and Ladder game

[Link] if an undirected graph contains cycle or not

[Link] given Binary Tree | Recursive and Iterative solution

[Link] maximum cost path in graph from given source to destination

[Link] shortest distance of every cell from landmine in a Maze

Sorting
[Link] sort | Iterative & Recursive

[Link] sort | Iterative & Recursive

[Link] sort | Iterative & Recursive

[Link] Sort Algorithm

[Link] Merge Sort Algorithm (Bottom-up Merge Sort)

[Link] Algorithm

[Link] Implementation of Quicksort

[Link] QuickSort

[Link] using Dutch National Flag Algorithm

[Link] Sort using Hoare’s Partitioning scheme

[Link] merge sort

[Link] Sort Algorithm

[Link] Sort | Sort elements by their frequency and Index

[Link] Sort | Sort elements of the array by order of elements defined by the
second array

[Link] Count of an array


[Link] positive and negative integers in linear time

[Link] Sort an Array with many Duplicated Values

[Link] the smallest window in array sorting which will make the entire array
sorted

[Link] largest number possible from set of given numbers

[Link] all zeros present in the array to the end

[Link] binary array in linear time

[Link] linked list containing 0’s, 1’s and 2’s

[Link] Sort Algorithm for Singly Linked List

[Link] anagrams together from given list of words

[Link] Selection Problem

[Link] sorting of given set of keys

[Link] Sort

[Link] M sorted lists of variable length

[Link] M sorted lists each containing N elements

[Link] all palindromic permutations of a string

[Link] all lexicographically next permutations of a string sorted in ascending


order

[Link] two sorted linked lists from their end

[Link] an array containing 0’s, 1’s and 2’s (Dutch national flag problem)

[Link] pair with given sum in the array

[Link] merge two sorted arrays

[Link] two arrays by satisfying given constraints

[Link] maximum product of two integers in an array

[Link] all distinct combinations of given length

[Link] all distinct combinations of given length with repetition allowed

[Link] Overlapping Intervals

[Link] all quadruplets with given sum | 4-sum problem extended

42.4 sum problem | Quadruplets with given sum

[Link] two numbers with maximum sum formed by array digits

[Link] a Triplet having Maximum Product in an Array


[Link] Minimum Product among all Combinations of Triplets in an Array

[Link] all distinct combinations of given length — Part 2

[Link] the surpasser count for each element of an array

Stack
[Link] Implementation

[Link] Implementation using Linked List

[Link] if given expression is balanced expression or not

[Link] duplicate parenthesis in an expression

[Link] given postfix expression

[Link] the given sequence to construct minimum number without repeated digits

[Link] Tree Traversal | Iterative & Recursive

[Link] Tree Traversal | Iterative & Recursive

[Link] Tree Traversal | Iterative & Recursive

[Link] ancestors of given node in a Binary Tree

[Link] if two given binary trees are identical or not | Iterative & Recursive

[Link] given text without reversing the individual words

[Link] all binary strings that can be formed from given wildcard pattern

[Link] Implementation of Quicksort

[Link] First Search (DFS) | Iterative & Recursive Implementation

[Link] given Binary Tree | Recursive and Iterative solution

[Link] leaf to root path for every leaf node in a binary tree

String
[Link] if given string is a rotated palindrome or not

[Link] Palindromic Substring (Non-DP Space Optimized Solution)

[Link] if repeated subsequence is present in the string or not

[Link] if strings can be derived from each other by circularly rotating them

[Link] if given set of moves is circular or not

[Link] given number into corresponding excel column name

[Link] if two strings are anagram or not

[Link] all binary strings that can be formed from given wildcard pattern
[Link] all interleavings of given strings

[Link] Strings

[Link] all possible palindromic substrings in a string

[Link] all possible combinations of words formed from mobile keypad

[Link] all possible combinations by replacing given digits with characters of the
corresponding list

[Link] all words from given list that follows same order of characters as given
pattern

[Link] first k non-repeating characters in a string in single traversal

[Link] anagrams together from given list of words

[Link] to Pattern Matching

[Link] remove all occurrences of ‘AB’ and ‘C’ from the string

[Link] even length palidromic sum substring

[Link] string in zig-zag form in k rows

[Link] given text without reversing the individual words

[Link] Length Encoding (RLE) data compression algorithm

[Link] an IP address

[Link] the longest substring of given string containing k distinct characters

[Link] all palindromic permutations of a string

[Link] all substrings of a string that are permutation of a given string

[Link] the longest substring of given string containing all distinct characters

[Link] all Permutations of a given string

[Link] Approach to find Permutations of a String in C++ and Java

[Link] all Permutations of a String in Java | Recursive & Iterative

[Link] all lexicographically next permutations of a string sorted in ascending


order

[Link] Lexicographically minimal string rotation

[Link] all strings of given length containing balanced parentheses

[Link] all N-digit strictly increasing numbers (Bottom-Up and Top-Down Approach)

[Link] all N-digit binary numbers having more 1’s than 0’s for any prefix

[Link] all N-digit numbers with given sum of digits


[Link] all N-digit binary numbers with k-bits set where k ranges from 1 to N

[Link] binary numbers between 1 to N

[Link] all combinations of non-overlapping substrings of a string

[Link] if given sentence is syntactically correct or not

[Link] rank of given string among all its lexicographically sorted


permutations

[Link] all Lexicographic Permutations of a String

[Link] all N-digit binary numbers with equal sum of bits in its two halves

[Link] if given string is interleaving of two other given strings

[Link] between Subarray, Subsequence and Subset

[Link]::next_permutation | Overview & Implementation in C++

[Link]::prev_permutation | Overview & Implementation in C++

[Link] of KMP Algorithm in C, C++ and Java

[Link] String without using Recursion

[Link] given string using Recursion

[Link] a String in Java in 10 different ways

[Link] if a given string is palindrome or not

[Link]-place remove all adjacent duplicates from the given string

[Link] the minimum number of inversions needed to make the given expression
balanced

[Link] all non-overlapping occurrences of the pattern

[Link] the longest palindrome by shuffling or deleting characters from a


string

[Link] if characters of a String follows a specified order or not

[Link] all combinations of phrases that can be formed by picking words from each
of the given lists

[Link] all extra spaces from a string

[Link] a string into all possible combinations of non-overlapping substrings

[Link] adjacent duplicate characters from a string

[Link] of words formed by replacing given numbers with corresponding


alphabets

[Link] Break Problem


[Link] Pattern Matching

[Link] number of times a pattern appears in given string as a subsequence

[Link] Levenshtein distance (Edit distance) problem

[Link] Common Subsequence | Introduction & LCS Length

[Link] Common Subsequence | Space optimized version

[Link] Common Subsequence of K-sequences

[Link] Common Subsequence | Finding all LCS

[Link] Repeated Subsequence problem

[Link] Palindromic Subsequence using Dynamic Programming

[Link] Common Substring problem

[Link] Common Supersequence | Introduction & SCS Length

[Link] Common Supersequence | Finding all SCS

[Link] Common Supersequence | Using LCS

[Link] Diff Utility

[Link] Break Problem | Using Trie Data Structure

[Link] minimum cuts needed for palindromic partition of a string

[Link] if a string is K-Palindrome or not

[Link] shortest route in a device to construct the given string

[Link] minimum number possible by doing at-most K swaps

[Link] if a pattern matches with a string or not

Trie
[Link] Implementation | Insert, Search and Delete

[Link] efficient Trie Implementation using Map | Insert, Search and Delete

3.C++ Implementation of Trie Data Structure

[Link] Common Prefix in given set of strings (using Trie)

[Link] sorting of given set of keys

[Link] maximum occurring word in given set of strings

[Link] first k maximum occurring words in given set of strings

[Link] Duplicate rows in a binary matrix

[Link] Break Problem | Using Trie Data Structure


Greedy
[Link] Selection Problem

[Link] Coding

[Link] Superstring Problem

[Link] Sequencing Problem with Deadlines

[Link] coloring of graph

[Link]’s Algorithm for finding Minimum Spanning Tree

[Link]-Source Shortest Paths — Dijkstra’s Algorithm

Puzzles
[Link] angle problem — Find angle between hour and minute hand

[Link] two numbers without using addition operator | 4 methods

[Link] power set of a given set

[Link] power function without using multiplication and division operators

[Link] all numbers between 1 to N without using semicolon

[Link] two numbers without using third variable | 5 methods

[Link] the if condition to print specific output

[Link] maximum, minimum of three numbers without using conditional statement and
ternary operator | 4 methods

[Link] numbers represented as sum of two cubes for two different pairs

[Link] “Hello World” with empty main() function | 3 methods

[Link] of Hanoi Problem

[Link] all numbers between 1 to N without using any loop | 4 methods

[Link] a semicolon without using semicolon anywhere in the program

[Link] two numbers without using multiplication operator or loops

[Link] square of a number without using multiplication and division operator | 3


methods

[Link] if a number is even or odd without using any conditional statement

[Link] both elements of a binary array to 0 in single line

[Link] minimum number without using conditional statement or ternary operator

[Link] Division of two numbers without using division operator (/)

[Link] 0 and 1 with 75% and 25% Probability

[Link] Desired Random Numbers With Equal Probability


[Link] 0, 1 and 2 with equal Probability using the specified function

[Link] Fair Results from a Biased Coin

[Link] numbers from 1 to 7 with equal probability using specified function

[Link] Ternary Operator Without Using Conditional Expressions

[Link] if two integers are equal without using comparison and arithmetic
operators

[Link] 0 and 1 with equal Probability using the specified function

[Link] Random Input from an Array according to given Probabilities

[Link] Fair Results from a Biased Coin

[Link] Puzzle

You might also like