An open API service indexing awesome lists of open source software.

https://github.com/riteshkumarshukla/dsa-must-do-questions

Unlock the Secrets of Problem-Solving: Dive into a curated collection of important and tricky Data Structures and Algorithms questions. Sharpen your coding skills, conquer technical interviews, and level up your software engineering journey with this comprehensive repository.
https://github.com/riteshkumarshukla/dsa-must-do-questions

Last synced: about 1 month ago
JSON representation

Unlock the Secrets of Problem-Solving: Dive into a curated collection of important and tricky Data Structures and Algorithms questions. Sharpen your coding skills, conquer technical interviews, and level up your software engineering journey with this comprehensive repository.

Awesome Lists containing this project

README

        

# Interview Preparation Questions - Data Structures and Algorithms

## DSA Decoded:
*Unleash your full potential in Data Structures and Algorithms with this meticulously crafted GitHub repository. Explore a diverse range of important and mind-bending questions to stretch your problem-solving abilities and solidify your understanding of core algorithms. Level up your coding game and stand out among your peers.*

## Table of Contents

- [Arrays](#arrays)
- [Strings](#strings)
- [Objects](#objects)
- [Linked List](#linked-list)
- [Queue](#queue)
- [Stack](#stack)

---

## Arrays

| No. | Question |
| --- | -------------------------------------------------------------------------------------------------------------------------- |
| 1. | Find the second largest element in an array. |
| 2. | Merge two sorted arrays into a sorted array without using extra space. |
| 3. | Rearrange an array in alternating positive and negative numbers. |
| 4. | Find the maximum difference between two elements in an array, where the smaller element appears before the larger element. |
| 5. | Find the equilibrium index in an array. |
| 6. | Count the number of pairs in an array whose sum is equal to a given target value. |
| 7. | Rearrange an array such that arr[i] becomes arr[arr[i]] with O(1) extra space. |
| 8. | Find the minimum and maximum element in an array with a minimum number of comparisons. |
| 9. | Rearrange an array in wave form. |
| 10. | Find the majority element in an array. |
| 11. | Find the missing number in an array of integers from 1 to N. |
| 12. | Given an array of integers, find the maximum subarray sum. |
| 13. | Rotate an array to the right by K steps. |
| 14. | Find the duplicate number in an array of integers from 1 to N. |
| 15. | Given an array of integers, find the product of all elements except the current one. |
| 16. | Find the kth largest element in an unsorted array. |
| 17. | Rearrange positive and negative numbers in an array. |
| 18. | Merge two sorted arrays into a single sorted array. |
| 19. | Find the peak element in an array. |
| 20. | Given an array, find the subarray with the maximum sum. |

## Strings

| No. | Question |
| --- | --------------------------------------------------------------------------------- |
| 1. | Reverse words in a given string. |
| 2. | Find the longest substring without repeating characters. |
| 3. | Convert a string to an integer (atoi). |
| 4. | Check if two strings are rotations of each other. |
| 5. | Check if a string is a valid palindrome considering only alphanumeric characters. |
| 6. | Print all permutations of a string. |
| 7. | Find the first non-repeating character in a string. |
| 8. | Implement strstr() (substring search). |
| 9. | Count and say the sequence. |
| 10. | Implement regular expression matching. |
| 11. | Reverse a string. |
| 12. | Check if a string is a palindrome. |
| 13. | Find the longest common prefix among a set of strings. |
| 14. | Determine if two strings are anagrams. |
| 15. | Count the occurrences of a substring in a given string. |
| 16. | Find the longest palindromic substring in a string. |
| 17. | Remove duplicate characters from a string. |
| 18. | Check if a string is a valid parentheses expression. |
| 19. | Compress a string by replacing repeated characters with their count. |
| 20. | Find the first non-repeating character in a string. |

## Objects

| No. | Question |
| --- | --------------------------------------------------------------------------------------------------- |
| 1. | Implement a key-value store using a linked list, where keys and values are stored as nodes. |
| 2. | Write a function to insert a new key-value pair into a key-value store. |
| 3. | Implement a key-value store using a balanced binary search tree (BST) data structure. |
| 4. | Write a function to retrieve all keys in a key-value store. |
| 5. | Implement a function to check if two key-value stores have the same set of keys. |
| 6. | Write a function to find the key with the maximum value in a key-value store. |
| 7. | Implement a function to calculate the average value of all keys in a key-value store. |
| 8. | Write a function to check if a key-value store is empty. |
| 9. | Implement a function to update the value associated with a given key in a key-value store. |
| 10. | Write a function to remove all key-value pairs with a specific value from a key-value store. |
| 11. | Implement a function to find the key(s) with the minimum value in a key-value store. |
| 12. | Write a function to count the number of key-value pairs in a key-value store with a specific value. |
| 13. | Implement a key-value store using a hash map data structure. |
| 14. | Write a function to retrieve the values associated with a given key prefix in a key-value store. |
| 15. | Implement a function to sort the key-value pairs in a key-value store based on the keys. |
| 16. | Write a function to get the value associated with the smallest key in a key-value store. |
| 17. | Implement a function to calculate the sum of all values in a key-value store. |
| 18. | Write a function to find the key-value pair with the largest key in a key-value store. |
| 19. | Implement a function to check if a key-value store contains a specific value. |
| 20. | Write a function to remove the key-value pair with the smallest key from a key-value store. |

## Linked List

| No. | Question |
| --- | ---------------------------------------------------------------------------------------- |
| 1. | Reverse a linked list in groups of a given size. |
| 2. | Check if a linked list is a palindrome. |
| 3. | Find the intersection point of two linked lists. |
| 4. | Remove duplicates from a sorted linked list. |
| 5. | Swap nodes in pairs in a linked list. |
| 6. | Find the nth node from the end of a linked list. |
| 7. | Detect and remove a loop in a linked list. |
| 8. | Add two numbers represented by linked lists. |
| 9. | Check if a linked list is cyclic or acyclic. |
| 10. | Implement a doubly linked list. |
| 11. | Implement a singly linked list and perform basic operations like insertion and deletion. |
| 12. | Reverse a linked list iteratively and recursively. |
| 13. | Detect if a linked list has a cycle and find the starting point of the cycle. |
| 14. | Merge two sorted linked lists into a single sorted list. |
| 15. | Find the middle element of a linked list. |
| 16. | Remove the Nth node from the end of a linked list. |
| 17. | Given a linked list, remove duplicates from it. |
| 18. | Check if a linked list is a palindrome. |
| 19. | Split a linked list into two halves. |
| 20. | Sort a linked list using a sorting algorithm. |

## Queue

| No. | Question |
| --- | --------------------------------------------------------------------------------------- |
| 1. | Implement a queue using two stacks. |
| 2. | Reverse the first K elements of a queue. |
| 3. | Design a circular queue. |
| 4. | Implement a priority queue. |
| 5. | Check if a queue is empty or full. |
| 6. | Design a queue using a linked list. |
| 7. | Generate binary numbers from 1 to N using a queue. |
| 8. | Implement a queue using a circular array. |
| 9. | Find the maximum element in a sliding window of size K using a queue. |
| 10. | Perform the interleave operation on a queue. |
| 11. | Implement a queue using an array. |
| 12. | Design a deque (double-ended queue) and implement its operations. |
| 13. | Implement a queue that supports enqueue, dequeue, and getFront operations in O(1) time. |
| 14. | Implement a circular buffer using a queue. |
| 15. | Perform a level-order traversal of a binary tree using a queue. |
| 16. | Implement a queue that supports peeking at the front and rear elements. |
| 17. | Implement a queue using a stack. |
| 18. | Design a queue that supports finding the minimum element in constant time. |
| 19. | Implement a priority queue using a binary heap. |
| 20. | Implement a blocking queue with a maximum size. |

## Stack

| No. | Question |
| --- | -------------------------------------------------------------------------------------------- |
| 1. | Design a stack that supports push, pop, and getMin operations in O(1) time. |
| 2. | Implement a stack that supports sorting its elements. |
| 3. | Check if parentheses in a string are balanced using a stack. |
| 4. | Evaluate a postfix expression using a stack. |
| 5. | Convert an infix expression to postfix using a stack. |
| 6. | Reverse a string using a stack. |
| 7. | Design a stack that supports getMin operation in O(1) time. |
| 8. | Implement a stack using a linked list. |
| 9. | Check if a given expression is balanced using a stack. |
| 10. | Implement a stack that supports push, pop, and getMin operations in O(1) space. |
| 11. | Implement a stack using an array. |
| 12. | Check if a given expression is balanced using a stack. |
| 13. | Reverse a stack using recursion. |
| 14. | Implement a stack that supports push, pop, and findMiddle operations in O(1) time. |
| 15. | Check if a string is a palindrome using a stack. |
| 16. | Sort a stack using another stack. |
| 17. | Implement a stack using two queues. |
| 18. | Design a stack that supports getMin, getMax, and getAverage operations in O(1) time. |
| 19. | Implement a stack that supports push, pop, and findMiddle operations in O(1) time and space. |
| 20. | Check if a string is balanced by checking its parentheses using a stack. |

# Time Complexity Reference Table

A reference table for different ranges of `n` values and their corresponding time complexities. 🚀

| n Range | Time Complexity |
|-----------------|-------------------|
| n ≤ 12 | ⏱️ O(1) |
| n ≤ 25 | ⏱️ O(log n) |
| n ≤ 100 | ⏱️ O(√n) |
| n ≤ 500 | ⏱️ O(n) |
| n ≤ 10^4 | ⏱️ O(n log n) |
| n ≤ 10^6 | ⏱️ O(n²) |
| n ≤ 10^8 | ⏱️ O(n²) or O(n³) or O(n log n) |
| n ≤ 10^9 | ⏱️ O(n log n) or O(n³) |
| n ≤ 10^12 | ⏱️ O(n log n) or O(n²) |
| n ≤ 10^18 | ⏱️ O(n log n) or O(n) |
| n ≤ 10^100 | ⏱️ O(n log n) |
| n > 10^100 | ⏱️ O(2^n) or O(n!) |

⚠️ Please note that this table provides a general overview and time complexities may vary depending on the problem and implementation details. Always consider the specific constraints and optimize your algorithms accordingly to avoid exceeding time limits.

Feel free to use this reference table when analyzing the time complexity of your algorithms! 😊