Top 100 Data Structure and Algorithms DSA Interview Questions Topic-wise

Last Updated : 08 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

DSA has been one of the most popular go-to topics for any interview, be it college placements, software developer roles, or any other technical roles for freshers and experienced to land a decent job. If you are among them, you already know that it is not easy to find the best DSA interview questions among the vast pool of available problems. So here we are, with the Top 100 most asked DSA interview questions to help you sail through your technical rounds.

If you are looking for a shorter list for quick revision, please refer to Top 75 DSA Questions.

Top 100 Data Structure and Algorithms (DSA) Interview Questions Topic-wise

Top 100 Data Structure and Algorithms (DSA) Interview Questions Topic-wise

In this Top 100 DSA interview questions, we have segregated the problems based on the Data structure or algorithm used to solve them. Without further delay, let us begin your interview preparations:

DSA Interview Questions on Array

  1. Check if pair with the given Sum exists in Array
  2. Best Time to Buy and Sell Stock
  3. Find duplicates
  4. Product of Array Except Self
  5. Maximum Subarray
  6. Maximum Product Subarray
  7. Find Minimum in Rotated Sorted Array
  8. Search in Rotated Sorted Array
  9. 3 Sum
  10. Container With Most Water
  11. Find the Factorial of a large number
  12. Trapping Rain Water
  13. Chocolate Distribution Problem
  14. Insert Interval
  15. Merge Intervals
  16. Non-overlapping Intervals

DSA Interview Questions on Matrix

  1. Set Matrix Zeroes
  2. Spiral Matrix
  3. Program to find the transpose of a matrix
  4. Word Search

DSA Interview Questions on String

  1. Longest Substring Without Repeating Characters
  2. Longest Repeating Character Replacement
  3. Smallest window in a String containing all characters of other String
  4. Check whether two Strings are anagram of each other
  5. print all anagrams together
  6. Check if given Parentheses expression is balanced or not
  7. Sentence Palindrome
  8. Longest Palindromic Substring
  9. Palindromic Substrings
  10. Longest Common Prefix

DSA Interview Questions on Linked List

  1. Reverse a Linked List
  2. Detect Cycle in a Linked List
  3. Merge Two Sorted Lists
  4. Merge K Sorted Lists
  5. Remove Nth Node From End Of List
  6. Reorder List
  7. Add 1 to a number represented as linked list
  8. Find the middle of a given linked list
  9. Delete last occurrence of an item from linked list

DSA Interview Questions on Stack & Queue

  1. Convert Infix expression to Postfix expression
  2. Next Greater Element
  3. Delete middle element of a stack
  4. Check mirror in n-ary tree
  5. The Celebrity Problem
  6. Length of the longest valid substring
  7. Print Right View of a Binary Tree
  8. Find the first circular tour that visits all petrol pumps

DSA Interview Questions on Tree

  1. Maximum Depth of Binary Tree
  2. Check if two trees have same structure
  3. Invert/Flip Binary Tree
  4. Binary Tree Maximum Path Sum
  5. Binary Tree Level Order Traversal
  6. Serialize and Deserialize Binary Tree
  7. Subtree of Another Tree
  8. Construct Binary Tree from Preorder and Inorder Traversal
  9. Validate Binary Search Tree
  10. Kth Smallest Element in a BST
  11. Lowest Common Ancestor of BST
  12. Implement Trie (Prefix Tree)
  13. Add and Search Word

DSA Interview Questions on Heap

  1. Top K Frequent Elements
  2. Find Median from Data Stream
  3. Largest triplet product in a stream
  4. Connect n ropes with minimum cost

DSA Interview Questions on Graph

  1. Clone Graph
  2. Course Schedule
  3. Pacific Atlantic Water Flow
  4. Number of Islands
  5. Longest Consecutive Sequence
  6. Snake and Ladder Problem
  7. Detect Cycle in a Directed Graph
  8. Bridges in a graph
  9. Check whether a given graph is Bipartite or not
  10. Find size of the largest region in Boolean Matrix
  11. Flood fill Algorithm
  12. Strongly Connected Components
  13. Topological Sorting

DSA Interview Questions on Dynamic Programming

  1. Count ways to reach the n’th stair
  2. Coin Change
  3. 0/1 Knapsack Problem
  4. Longest Increasing Subsequence
  5. Longest Common Subsequence
  6. Word Break Problem
  7. Dice Throw 
  8. Egg Dropping Puzzle
  9. Matrix Chain Multiplication
  10. Combination Sum
  11. Subset Sum Problem
  12. Find maximum possible stolen value from houses
  13. Count Possible Decodings of a given Digit Sequence
  14. Unique paths in a Grid with Obstacles
  15. Jump Game
  16. Cutting a Rod
  17. Maximum Product Cutting
  18. Count number of ways to cover a distance

DSA Interview Questions on Bit Manipulations

  1. Number of 1 Bits
  2. Counting Bits
  3. Missing Number
  4. Reverse Bits
  5. Find XOR of all subsets of a set

Related posts:

Some other important Tutorials:



Previous Article
Next Article

Similar Reads

DP Problems Topic Wise
DP Problems on MathsFibonacci NumberTribonacci NumbersLucas NumberBinomial CoefficientPascal's Triangle GenerationNth Row of Pascal TriangleCatalan NumberMatrix Chain MultiplicationDP Problems on StringsLongest Common SubstringLongest Palindromic SubstringWord BreakEdit DistanceK PalindromeMinimum Deletions to make PalidromeMinimum Cost to Make Str
1 min read
String Problems Topic Wise
In this post, string problems based on different topics are mentioned. Please refer String Data Structure article for fundamentals, basic operations and problems based on difficulty. Binary String:Check if all bits can be made same by single flipNumber of flips to make binary string alternateBinary representation of next numberMin flips of continuo
2 min read
Maths for Data Structure and Algorithms (DSA) | A Complete Guide
Maths is a fundamental component of learning Data Structure and Algorithms, just like in programming. Maths is primarily used to evaluate the effectiveness of different algorithms. However, there are situations when the answer requires some mathematical understanding or the problem has mathematical characteristics and certain problems demand more t
15+ min read
What is DSA | DSA Full Form
What is DSA?DSA(Data Structures and Algorithms) is defined as a combination of two separate yet interrelated topics – Data Structure and Algorithms. DSA is one of the most important skills that every computer science student must have. It is often seen that people with good knowledge of these technologies are better programmers than others and thus
2 min read
Search in a Row-wise and Column-wise Sorted 2D Array using Divide and Conquer algorithm
Given an n x n matrix, where every row and column is sorted in increasing order. Given a key, how to decide whether this key is in the matrix. A linear time complexity is discussed in the previous post. This problem can also be a very good example for divide and conquer algorithms. Following is divide and conquer algorithm.1) Find the middle elemen
15+ min read
Sort the matrix row-wise and column-wise
Given a n x n matrix. The problem is to sort the matrix row-wise and column wise. Examples: Input : mat[][] = { {4, 1, 3}, {9, 6, 8}, {5, 2, 7} } Output : 1 3 4 2 5 7 6 8 9 Input : mat[][] = { {12, 7, 1, 8}, {20, 9, 11, 2}, {15, 4, 5, 13}, {3, 18, 10, 6} } Output : 1 5 8 12 2 6 10 15 3 7 11 18 4 9 13 20 Approach: Following are the steps: Sort each
9 min read
Largest row-wise and column-wise sorted sub-matrix
Given an N * M matrix mat[][], the task is to find the area-wise largest rectangular sub-matrix such that each column and each row of the sub-matrix is strictly increasing. Examples: Input: mat[][] = {{1, 2, 3}, {4, 5, 6}, {1, 2, 3}} Output: 6 Largest sub-matrix will be {{1, 2, 3}, {4, 5, 6}}. Number of elements in this sub-matrix = 6. Input: mat[]
13 min read
Maximum sum of any submatrix of a Matrix which is sorted row-wise and column-wise
Given a matrix mat[][] whose elements are sorted both row-wise and column-wise. The task is to find the maximum sum of any submatrix from the given matrix mat[][]. Examples: Input: mat[][] = { {-6, -4, -1}, {-3, 2, 4}, {2, 5, 8}} Output: 19 Explanation: The largest submatrix is given by: 2 4 5 8Input: mat[][] = { {-4, -3}, {-2, -1} } Output: -1 Exp
10 min read
Encode given String by inserting in Matrix column-wise and printing it row-wise
Given a string S and an integer R, the task is to encode the string by first filling each character in column wise manner from top to bottom in a matrix having R rows and then printing the matrix row-wise. Examples: Input: S = "abcdefgh", R = 3Output: adgbehcfExplanation: Matrix formed is:a d gb e hc fSo when printed row wise it gives the encoded s
4 min read
Count number of islands where every island is row-wise and column-wise separated
Given a rectangular matrix which has only two possible values 'X' and 'O'. The values 'X' always appear in form of rectangular islands and these islands are always row-wise and column-wise separated by at least one line of 'O's. Note that islands can only be diagonally adjacent. Count the number of islands in the given matrix. Examples: mat[M][N] =
14 min read
Count Negative Numbers in a Column-Wise and Row-Wise Sorted Matrix
Find the number of negative numbers in a column-wise / row-wise sorted matrix M[][]. Suppose M has n rows and m columns. Example: Input: M = [-3, -2, -1, 1] [-2, 2, 3, 4] [4, 5, 7, 8] Output : 4 We have 4 negative numbers in this matrix We strongly recommend you to minimize your browser and try this yourself first. Naive Solution: Here's a naive, n
15+ min read
Count zeros in a row wise and column wise sorted matrix
Given a N x N binary matrix (elements in matrix can be either 1 or 0) where each row and column of the matrix is sorted in ascending order, count number of 0s present in it.Expected time complexity is O(N). Examples: Input: [0, 0, 0, 0, 1] [0, 0, 0, 1, 1] [0, 1, 1, 1, 1] [1, 1, 1, 1, 1] [1, 1, 1, 1, 1] Output: 8 Input: [0, 0] [0, 0] Output: 4 Input
8 min read
Check if a grid can become row-wise and column-wise sorted after adjacent swaps
Given a grid of size n x len filled with lowercase characters. We can swap two adjacent characters in the same row and column. Now we have to check whether it is possible to arrange in such a order that every row and every column in the grid is lexicographically sorted. Examples: Input : abcde fghij olmkn trpqs xywuv Output : Yes Explanation : The
5 min read
Search in a row wise and column wise sorted matrix
Given an N X N matrix and an integer X, find the position of X in the matrix if it is present. Otherwise, print "Element not found". Every row and column of the matrix is sorted in increasing order. Examples: Input: mat[4][4] = { {10, 20, 30, 40}, X = 29 {15, 25, 35, 45}, {27, 29, 37, 48}, {32, 33, 39, 50}} Output: Found at (2, 1)Explanation: Eleme
13 min read
Kth smallest element in a row-wise and column-wise sorted 2D array
Given an n x n matrix, where every row and column is sorted in non-decreasing order. Find the kth smallest element in the given 2D array. Example: Input:k = 3 and array = 10, 20, 30, 40 15, 25, 35, 45 24, 29, 37, 48 32, 33, 39, 50 Output: 20Explanation: The 3rd smallest element is 20 Input:k = 7 and array = 10, 20, 30, 40 15, 25, 35, 45 24, 29, 37,
15+ min read
Javascript Program to Sort the matrix row-wise and column-wise
Given a n x n matrix. The problem is to sort the matrix row-wise and column-wise. Examples: Input : mat[][] = { {4, 1, 3}, {9, 6, 8}, {5, 2, 7} }Output : 1 3 4 2 5 7 6 8 9Input : mat[][] = { {12, 7, 1, 8}, {20, 9, 11, 2}, {15, 4, 5, 13}, {3, 18, 10, 6} } Output : 1 5 8 12 2 6 10 15 3 7 11 18 4 9 13 20Approach: The following are the steps: Sort each
3 min read
Learn DSA with Python | Python Data Structures and Algorithms
This tutorial is a beginner-friendly guide for learning data structures and algorithms using Python. In this article, we will discuss the in-built data structures such as lists, tuples, dictionaries, etc, and some user-defined data structures such as linked lists, trees, graphs, etc, and traversal as well as searching and sorting algorithms with th
15+ min read
What to do if I get stuck in Data Structures and Algorithms (DSA)?
Learning Data Structures and Algorithms is like a big adventure where you explore various techniques that tell us how to solve complex problems in computer science. It's like solving a puzzle where you might not be sure what piece goes where. Thus there are times when you might feel stuck while learning DSA. This blog will help to overcome those di
4 min read
Data Structures and Algorithms (DSA) MCQ Quiz Online
Welcome to our Data Structures and Algorithms (DSA) MCQ Quiz Online! This DSA MCQ is all about Quizzes for solving problems and learning the fundamentals of Algorithms and Data Structures. You'll see multiple-choice questions (MCQs) that test how well you understand the basics and Data structure Algorithms. We'll cover every topic of DSA like Array
4 min read
Real-life Applications of Data Structures and Algorithms (DSA)
You may have heard that DSA is primarily used in the field of computer science. Although DSA is most commonly used in the computing field, its application is not restricted to it. The concept of DSA can also be found in everyday life. Here we'll address the common concept of DSA that we use in our day-to-day lives. Application of DataStructure Appl
10 min read
Most Asked Problems in Data Structures and Algorithms | Beginner DSA Sheet
In this Beginner DSA Sheet for Data Structures and Algorithms, we have curated a selective list of problems for you to solve as a beginner for DSA. After learning the fundamentals of programming, choosing a programming language, and learning about Data Structure and Algorithms and their space-time complexity, it becomes necessary to practice the pr
3 min read
Row-wise vs column-wise traversal of matrix
Two common ways of traversing a matrix are row-major-order and column-major-order Row Major Order: When matrix is accessed row by row. Column Major Order: When matrix is accessed column by column.Examples: Input : mat[][] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} Output : Row-wise: 1 2 3 4 5 6 7 8 9 Col-wise : 1 4 7 2 5 8 3 6 9 In many problems (like Sea
6 min read
Top 75 DSA Questions
In this post, we present a list of the top 75 data structures and algorithms (DSA) coding questions to help you prepare for a thorough revision for interviews at leading tech companies like Meta, Google, Amazon, Apple, Microsoft, etc. This list helps you to cover an extensive variety of DSA Coding questions ensuring you don't miss any key concepts
2 min read
Data Structures & Algorithms (DSA) Guide for Google Tech interviews
Google is known for its rigorous and highly competitive technical interviews. These interviews are designed to assess a candidate's problem-solving abilities, technical knowledge, and cultural fit with the company. Preparing for technical interviews at top companies like Google requires a solid understanding of Data Structures and Algorithms (DSA).
9 min read
Top 12 Data Structure Algorithms to Implement in Practical Applications in 2021
New Year...New Beginning...!!! What's your plan for this year??? (Being a programmer) Of course, if you're a programmer then this year you will also write the code, build the projects and you will solve a lot of coding questions. Let's talk about Data Structures and Algorithms... Heart of computer science and the programmer's breath to live in the
14 min read
Static Data Structure vs Dynamic Data Structure
Data structure is a way of storing and organizing data efficiently such that the required operations on them can be performed be efficient with respect to time as well as memory. Simply, Data Structure are used to reduce complexity (mostly the time complexity) of the code. Data structures can be two types : 1. Static Data Structure 2. Dynamic Data
4 min read
API Testing Interview Questions for 2024: Top 50 Interview Questions
API testing checks if application programming interfaces (APIs) work as expected in terms of functionality, performance, security, and reliability. Unlike UI testing, which focuses on how an app looks, API testing focuses on how it works behind the scenes. With APIs being essential in modern software, learning API testing is crucial for anyone in q
15+ min read
Quiz on Algorithms | DSA MCQs
Welcome to our Algorithms MCQ Quiz Online! This ALgorithm MCQ is all about Quizzes of solving problems and learning the fundamentals of Algorithms. You’ll see multiple-choice questions (MCQs) that test how well you understand the basics and advanced concepts of Algorithms. We’ll cover every topic of algorithms like sorting, searching, Greedy algori
2 min read
Active Directory Interview Questions - Top 50+ Questions and Answers for 2024
Active Directory (AD) is a crucial component of modern enterprise IT infrastructure, providing centralized authentication, authorization, and directory services for Windows-based networks. As organizations continue to rely heavily on AD for managing user identities, access controls, and network resources, the demand for skilled AD administrators an
15+ min read
Teacher Interview Questions - Top 70 Questions and Answers for 2024
Teaching is a noble profession that requires a unique blend of knowledge, skills, and passion. As educators, teachers play a crucial role in shaping the minds of future generations, fostering critical thinking, and nurturing the potential of each student. In today's rapidly evolving educational landscape, teachers must be prepared to meet diverse c
15+ min read
three90RightbarBannerImg