> Data Structures and Algorithms (DSA) Interview Questions

Data Structures and Algorithms (DSA) Interview Questions

Data Structures and Algorithms (DSA) Interview Questions to learn data structures and algorithms for job interview questions and improve your problem solving skills to provide efficient solution to complex problems.

The best way to learn data structures and algorithms will be learn the concepts, implement it, solve the problems using concepts and then write the program in programming language you love most. [DSA Roadmap]

Recommended Book :
Comprehensive Data Structures and Algorithms in Java
Comprehensive Data Structures and Algorithms in C++

CourseGalaxy Problem Set 107

First learn the data Structures and Algorithms and implement it. Then move to problems. [DSA Roadmap] There are 107 problems in this CourseGalaxy Problem Set 107.

Arrays

  • Reverse the elements of an array.
  • Rotate left an array by k elements.
  • Solutions
    • 2 loops
    • Reverse of array elements
    • reverse(arr, 0, k-1);
      reverse(arr, k, n-1);
      reverse(arr, 0, n-1);

  • Pascal's triangle.
  • Remove duplicate elements from an unsorted array.
  • Solutions
    • 2 loops
    • Sort it and then traverse to remove duplicates
    • Hashing
    • BST, remove duplicates while insertion
  • Leaders in an array
  • Sliding window maximum
  • Rotate a matrix 90 degree
  • Majority elements
  • Product of array except self
  • Inversions in an array
  • Print a square matrix spirally.
  • Merge two sorted arrays without extra space
  • Left side sum of array elements equal to right side sum

Strings

  • Reverse the letters in the words of a string.
  • Find the first non-repeating character in a string.
  • Longest substring without repeating characters
  • Print all permutations of a given string
  • Change the string to be in alphabetical order
  • Integer to roman
  • Longest palindrome in a string
  • Rotate left string1 k times to match with staring2

Linked List

  • Reverse a linked list.
  • Find out the middle node of a single linked list.
  • Find the nth node from the end of a single linked list.
  • Rotate the list left by k nodes
  • Insert a node just before and just after a node pointed to by a pointer p, without using the pointer start.
  • Exchange the pair in a single linked list
  • Find the merge point of two single linked list (Y type).
  • Insert, detect, remove a cycle in linked list.
  • Intersection of two single linked lists (elements common to both the lists).
  • Union of two single linked lists (element included only once).
  • Reorder list
  • Copy list with random pointers

Stacks and Queues

  • Reverse a string
  • Implement 2 stack in an array
  • Min Stack
  • Implement 2 queue in an array
  • Evaluation of postfix
  • Valid parentheses
  • Largest rectangle In histogram
  • Next greater element

Recursion

  • Program to find the factorial of a number using recursion.
  • Summation of numbers from 1 to n
  • Displaying numbers from 1 to n
  • Display and find out the sum of series 1 + 2 + 3 + 4 + 5 +.......
  • Display digits of an integer number and finds the sum of digits of that number
  • Convert a positive decimal number to Binary, Octal or //Hexadecimal
  • Find the exponentiation of a number (a power n, example 2 power 3 = 8)
  • Display the prime factors of a number

Trees

  • Level order traversal of a binary tree
  • Height of a binary tree
  • K-th smallest element in a binary search tree
  • Check if a binary tree is BST or not
  • Find minimum and maximum in binary search tree.
  • Construct binary tree from postorder and inorder traversal
  • Check if two trees are identical or not
  • Find the inorder predecessor/successor of a given Key in BST

Graphs

  • Number of connected components in a directed graph
  • Clone a graph
  • Detect cycle in a directed graph
  • Strongly connected components
  • Is the graph Bipartite?
  • Find if a graph is strongly connected or not
  • Number of islands
  • Course schedule

Sorting, Searching, Hashing

  • Search in a rotated sorted array
  • Design hashmap
  • Search a 2D matrix
  • Partition an array such that all the even numbers are on the left side of array and odd numbers on the right side.
  • Find the k-th smallest element in an array.
  • Count negative numbers in a sorted matrix
  • Maximum consecutive ones
  • Divide two integers

Heap

  • K-th largest element
  • Top k most frequent elements
  • Merge k sorted arrays
  • Merge k sorted linked lists
  • Find median from data stream

Trie

  • Implement trie - insertion, search, deletion, startsWith, display
  • Removal of longest key in a trie
  • Number of keys with common prefix in trie
  • Keys starts with and ends with in trie
  • Finding longest key in trie

Bit Manipulation

  • Reverse integer
  • Find if a number is power of two
  • Power set
  • Single number
  • Missing number
  • Number of bits to be flipped to convert A to B
  • Reverse bits
  • Sum of two integers

Backtracking

  • Palindrome partitioning
  • Subsets
  • Print all permutations of a string
  • N Queens
  • Sudoko solver
  • Word search
  • Rat in a maze
  • Combination sum

Dynamic programming

  • Coin change
  • 0-1 Knapsack
  • Fibonacci number
  • Longest increasing subsequence
  • Egg dropping
  • Edit distance
  • Climbing stairs
  • Matrix chain multiplication

Data Structures and Algorithms (DSA) Online Courses

Data Structures and Algorithms in C/C++/C#/Java/Python (DSA) online courses.

Your Instructors


Suresh Kumar Srivastava has 20+ years of experience in software industry - Alcatel, BNY Mellon, Unisys and has worked on architecture and design of multiple products. He is author of popular books "C in Depth", "Data Structures through C in Depth" and "Comprehensive Data Structures and Algorithms in C++/Java" that helped 250,000+ students. He has done 'B' Level from NIELIT. He has worked on Compilers, Linkers, Debuggers, IDEs, System Utilities, System Management and Telecom/Mobile/Systems tools development. He runs online learning site CourseGalaxy and loves doing software architecture, design, coding and product engineering.

Deepali Srivastava has a Master's degree in Mathematics and is an author and educator in the field of computer science and programming. Her books "Ultimate Python Programming", "C in Depth", "Data Structures through C in Depth" and "Comprehensive Data Structures and Algorithms in C++/Java" are widely used as reference materials by students, programmers and professionals looking to enhance their understanding of programming languages and data structures. In addition to her writing, Deepali Srivastava has been involved in creating online video courses on Data structures and Algorithms, Linux and Python programming. Her books and courses have helped 350,000+ students learn computer science concepts.
This article provides Data Structures and Algorithms (DSA) Interview Questions in C/C++/C#/Java/Python.