Data Structures and Algorithms Practice Questions
console.log('Hello, Duniya!')
Arrays and Strings
- Find the sum of two numbers.
- Calculate the factorial of a number.
- Reverse a string.
- Check if a number is prime.
- Find the maximum element in an array.
- Merge two sorted arrays.
- Remove duplicates from an array.
- Check if two strings are anagrams.
- Find the intersection of two arrays.
- Count the occurrences of a character in a string.
- Move all zeroes to the end of an array.
- Rotate an array to the right by k steps.
- Find the majority element in an array.
- Find the longest increasing subsequence in an array.
- Find the maximum subarray sum.
Linked Lists
- Implement a linked list.
- Detect a loop in a linked list.
- Remove a loop in a linked list.
- Reverse a linked list.
- Implement a circular linked list.
- Find the intersection point of two linked lists.
- Convert a binary search tree to a sorted doubly linked list.
- Check if a linked list is a palindrome.
- Implement a stack using queues.
- Implement a queue using stacks.
Trees and Binary Search Trees
- Implement a binary tree.
- Find the height of a binary tree.
- Traverse a binary tree in-order.
- Traverse a binary tree pre-order.
- Traverse a binary tree post-order.
- Check if a binary tree is balanced.
- Find the lowest common ancestor in a binary tree.
- Serialize and deserialize a binary tree.
- Convert a sorted array to a balanced BST.
- Check if a binary tree is a binary search tree (BST).
- Find the diameter of a binary tree.
- Convert a binary search tree to a sorted array.
Graphs
- Implement a basic graph representation (adjacency matrix/adjacency list).
- Find the shortest path in a graph using BFS.
- Find the shortest path in a graph using Dijkstra's algorithm.
- Find the shortest path in a graph using Bellman-Ford algorithm.
- Check if a graph is cyclic.
- Topological sort of a directed graph.
- Kruskal's algorithm for minimum spanning tree.
- Prim's algorithm for minimum spanning tree.
- Depth-first search (DFS) on a graph.
- Check if a directed graph has a Eulerian path or circuit.
- Find the articulation points in a graph.
- Find the strongly connected components in a directed graph.
- Detect a cycle in a directed graph.
- Check if a graph is bipartite.
- Find the topological ordering of a DAG.
- Find the number of ways to reach a target sum using coins.
- Count the number of paths in a grid from the top-left to the bottom-right.
- Implement a breadth-first search (BFS) on a matrix.
- Implement a depth-first search (DFS) on a matrix.
Sorting and Searching
- Implement binary search.
- Sort an array using quicksort.
- Sort an array using mergesort.
- Implement a heap (min-heap or max-heap).
- Find the median of two sorted arrays.
Stacks and Queues
- Implement a stack.
- Implement a queue.
- Implement a circular queue.
- Implement a stack with minimum element retrieval in O(1) time.
- Implement a queue using stacks.
Hashing
- Implement a hash table.
- Implement a hash map from scratch.
- Implement a basic bloom filter.
Dynamic Programming
- Calculate the Fibonacci sequence.
- Find the longest common prefix in an array of strings.
- Evaluate a postfix expression.
- Evaluate an infix expression.
- Find the longest common subsequence of two strings.
Miscellaneous
- Count set bits (1s) in a binary number.
- Convert a Roman numeral to an integer.
- Convert a decimal number to binary.
- Find the square root of a number.
- Determine if a number is a power of two.
- Generate all possible subsets of a set.
- Generate all permutations of a string.
- Find the first non-repeating character in a string.
- Implement an LRU (Least Recently Used) cache.
- Implement an algorithm for the Tower of Hanoi problem.
- Implement a basic regular expression matcher.
- Implement a basic LZW compression algorithm.
Advanced Topics
- Implement a Trie (prefix tree).
- Implement a priority queue.
- Implement a disjoint-set (union-find) data structure.
- Find the articulation points in a graph.
- Find the strongly connected components in a directed graph.
- Check if a string has valid parentheses.
- Find the diameter of a binary tree.
- Convert a sorted array to a balanced BST.
- Find the kth smallest/largest element in an array.
- Find the longest palindrome substring in a string.
- Implement a basic regular expression matcher.
- Implement a basic bloom filter.
- Implement a basic LZW compression algorithm.
- Check if a graph is connected.