DSA Guide
Beginner Level DSA Sheet

Data Structures and Algorithms Practice Questions

console.log('Hello, Duniya!')

Arrays and Strings

  1. Find the sum of two numbers.
  2. Calculate the factorial of a number.
  3. Reverse a string.
  4. Check if a number is prime.
  5. Find the maximum element in an array.
  6. Merge two sorted arrays.
  7. Remove duplicates from an array.
  8. Check if two strings are anagrams.
  9. Find the intersection of two arrays.
  10. Count the occurrences of a character in a string.
  11. Move all zeroes to the end of an array.
  12. Rotate an array to the right by k steps.
  13. Find the majority element in an array.
  14. Find the longest increasing subsequence in an array.
  15. Find the maximum subarray sum.

Linked Lists

  1. Implement a linked list.
  2. Detect a loop in a linked list.
  3. Remove a loop in a linked list.
  4. Reverse a linked list.
  5. Implement a circular linked list.
  6. Find the intersection point of two linked lists.
  7. Convert a binary search tree to a sorted doubly linked list.
  8. Check if a linked list is a palindrome.
  9. Implement a stack using queues.
  10. Implement a queue using stacks.

Trees and Binary Search Trees

  1. Implement a binary tree.
  2. Find the height of a binary tree.
  3. Traverse a binary tree in-order.
  4. Traverse a binary tree pre-order.
  5. Traverse a binary tree post-order.
  6. Check if a binary tree is balanced.
  7. Find the lowest common ancestor in a binary tree.
  8. Serialize and deserialize a binary tree.
  9. Convert a sorted array to a balanced BST.
  10. Check if a binary tree is a binary search tree (BST).
  11. Find the diameter of a binary tree.
  12. Convert a binary search tree to a sorted array.

Graphs

  1. Implement a basic graph representation (adjacency matrix/adjacency list).
  2. Find the shortest path in a graph using BFS.
  3. Find the shortest path in a graph using Dijkstra's algorithm.
  4. Find the shortest path in a graph using Bellman-Ford algorithm.
  5. Check if a graph is cyclic.
  6. Topological sort of a directed graph.
  7. Kruskal's algorithm for minimum spanning tree.
  8. Prim's algorithm for minimum spanning tree.
  9. Depth-first search (DFS) on a graph.
  10. Check if a directed graph has a Eulerian path or circuit.
  11. Find the articulation points in a graph.
  12. Find the strongly connected components in a directed graph.
  13. Detect a cycle in a directed graph.
  14. Check if a graph is bipartite.
  15. Find the topological ordering of a DAG.
  16. Find the number of ways to reach a target sum using coins.
  17. Count the number of paths in a grid from the top-left to the bottom-right.
  18. Implement a breadth-first search (BFS) on a matrix.
  19. Implement a depth-first search (DFS) on a matrix.

Sorting and Searching

  1. Implement binary search.
  2. Sort an array using quicksort.
  3. Sort an array using mergesort.
  4. Implement a heap (min-heap or max-heap).
  5. Find the median of two sorted arrays.

Stacks and Queues

  1. Implement a stack.
  2. Implement a queue.
  3. Implement a circular queue.
  4. Implement a stack with minimum element retrieval in O(1) time.
  5. Implement a queue using stacks.

Hashing

  1. Implement a hash table.
  2. Implement a hash map from scratch.
  3. Implement a basic bloom filter.

Dynamic Programming

  1. Calculate the Fibonacci sequence.
  2. Find the longest common prefix in an array of strings.
  3. Evaluate a postfix expression.
  4. Evaluate an infix expression.
  5. Find the longest common subsequence of two strings.

Miscellaneous

  1. Count set bits (1s) in a binary number.
  2. Convert a Roman numeral to an integer.
  3. Convert a decimal number to binary.
  4. Find the square root of a number.
  5. Determine if a number is a power of two.
  6. Generate all possible subsets of a set.
  7. Generate all permutations of a string.
  8. Find the first non-repeating character in a string.
  9. Implement an LRU (Least Recently Used) cache.
  10. Implement an algorithm for the Tower of Hanoi problem.
  11. Implement a basic regular expression matcher.
  12. Implement a basic LZW compression algorithm.

Advanced Topics

  1. Implement a Trie (prefix tree).
  2. Implement a priority queue.
  3. Implement a disjoint-set (union-find) data structure.
  4. Find the articulation points in a graph.
  5. Find the strongly connected components in a directed graph.
  6. Check if a string has valid parentheses.
  7. Find the diameter of a binary tree.
  8. Convert a sorted array to a balanced BST.
  9. Find the kth smallest/largest element in an array.
  10. Find the longest palindrome substring in a string.
  11. Implement a basic regular expression matcher.
  12. Implement a basic bloom filter.
  13. Implement a basic LZW compression algorithm.
  14. Check if a graph is connected.