Data Structures and Algorithms Problem Set

Here we have listed topic-wise 100 problems asked during the interview of companies
Important Suggestions

Problem set has covered all the important approaches for cracking any coding interview. You could easily apply these ideas to solve other similar problems.

Several problems in the set can be solved using more than one approaches. This will help you to understand ideas to improve the time and space complexity.

We recommend to follow these five steps of problem solving :

  1. Understanding the problem
  2. Designing the brute force or basic solution
  3. Improving the time and space complexity
  4. Writing pseudo code on paper and checking boundary conditions
  5. Programming language implementation and running the test cases
If you have any difficulty in solving problems in a topic then we encourage to learn or revise key concepts related to the topic. Key idea of learning algorithm is - Doing practice and never give up!

Data Structures and Algorithms Problem Set
#TitleSolutionDifficultyCompanies

1.

Roman To Integer

MEDIUM
Amazon
Microsoft
Facebook

2.

Reverse Bits

EASY
Amazon

3.

Square Root of Integer

MEDIUM
Amazon
Microsoft
Facebook

4.

Calculate power function

EASY
Google
LinkedIn
Amazon

5.

Greatest Common Divisor

MEDIUM
Google

6.

Find the Closest Palindrome

HARD
Microsoft
Amazon

7.

Rotate matrix

MEDIUM
Google

8.

Spiral Matrix

MEDIUM
Microsoft
Amazon

9.

Wave Array

EASY
Amazon
Google
Adobe

10.

Set Matrix Zeroes

MEDIUM
Amazon
Google

11.

maximum j – i such that A[j] > A[i]

MEDIUM
Google
Amazon
Adobe

12.

Move zeroes to an end

EASY
Facebook
Uber

13.

Merge two sorted arrays

MEDIUM
Microsoft
Adobe

14.

Container with Most Water

MEDIUM
Amazon
Google
Facebook
Adobe

15.

Remove duplicates from sorted array

MEDIUM
Amazon
Microsoft
Google

16.

Find an element in Bitonic array

EASY
Amazon

17.

Find minimum element in sorted and rotated array

MEDIUM
Facebook

18.

Median of two sorted array of same size

HARD
Amazon
Microsoft
Google

19.

Inversion count in an array

HARD
Amazon
Google

20.

Search for a Range in a sorted array

EASY
Microsoft
Google

21.

Longest Common Prefix

HARD
Amazon
Google

22.

Median in row wise sorted matrix

MEDIUM
Amazon

23.

Swap List Nodes in pairs

EASY
Amazon
Microsoft

24.

Add Two Numbers as Lists

MEDIUM
Amazon
Microsoft
Facebook

25.

Check if a singly linked list is palindrome

MEDIUM
Amazon
Microsoft

26.

Reverse a linked list from position m to n

MEDIUM
Amazon
Microsoft
Facebook

27.

Detect and Remove Loop in a Linked List

HARD
Amazon
Microsoft

28.

Merge Two Sorted Lists

EASY
Amazon
Microsoft
Yahoo

29.

Remove Nth Node from List End

MEDIUM
Amazon

30.

Sort a linked list using insertion sort

MEDIUM
Microsoft
Google

31.

Find next greater element in an array

MEDIUM
Amazon
Microsoft

32.

Trapping rain water

HARD
Amazon
Google

33.

Merge overlapping intervals

MEDIUM
Amazon
Google

34.

Largest Rectangle in Histogram

HARD
Amazon
Google
Facebook

35.

Check for balanced parentheses in an expression

MEDIUM
Amazon
Microsoft

36.

Min Stack Problem

EASY
Amazon
Microsoft
Yahoo
Adobe

37.

LRU Cache implementation

HARD
Amazon
Microsoft
Adobe
Google

38.

Sort a stack using another stack

MEDIUM
Amazon
Microsoft

39.

Lowest Common Ancestor of a Binary tree

MEDIUM
Amazon
Google
Microsoft
Facebook
Adobe

40.

Path sum in binary tree

EASY
Amazon
Microsoft
Yahoo

41.

Min Depth of Binary Tree

EASY
Amazon
Facebook

42.

Binary Tree Zigzag Level Order Traversal

MEDIUM
Amazon
Microsoft

43.

Invert Binary Tree

MEDIUM
Amazon
Google

44.

Flatten Binary Tree to Linked List

MEDIUM
Amazon
Microsoft
Yahoo
Adobe

45.

Find diameter of binary tree

MEDIUM
Facebook
Google
Amazon

46.

All Nodes Distance K in Binary Tree

MEDIUM
Microsoft

47.

Merge two binary tree

EASY
Amazon
Microsoft

48.

Shortest Unique Prefix

HARD
Google

49.

Sorted Array To Balanced BST

EASY
Amazon

50.

K-th largest element in BST

MEDIUM
Amazon

51.

Minimum absolute difference in BST

EASY
Google

52.

Recover Binary Search Tree

HARD
Amazon
Microsoft

53.

Merge Two BST

MEDIUM
Google
Amazon
Microsoft

54.

Lowest Common Ancestor of a BST

MEDIUM
Amazon
Microsoft

55.

K Pairs with Smallest Sums

MEDIUM
Google

56.

Sliding window maximum

HARD
Amazon
Google

57.

Merge K sorted list

HARD
Amazon
Google

58.

Convert a min heap to max heap

MEDIUM
Google

59.

Check if two arrays are equal or not

EASY
Amazon
Goldman Sachs

60.

Intersection of two unsorted array

MEDIUM
Google
Facebook

61.

Longest Consecutive Sequence

HARD
Amazon
Google

62.

Valid Anagram

MEDIUM
Google
Amazon
Microsoft

63.

Majority Element

MEDIUM
Amazon
Microsoft
Yahoo
Google

64.

Sort Characters by Frequency

MEDIUM
Facebook
Google

65.

First Unique Character in a String

EASY
Amazon
Microsoft

66.

Triplet with zero sum

MEDIUM
Facebook
Amazon
Microsoft

67.

First missing positive

MEDIUM
Amazon

68.

Largest subarray with 0 sum

HARD
Microsoft

69.

Max points on the straight line

HARD
Amazon
Google

70.

Climbing Stairs Problem

EASY
Amazon
Google

71.

Matrix Chain Multiplication

HARD
Amazon
Microsoft

72.

Longest Increasing subsequence

MEDIUM
Amazon
Microsoft
Facebook

73.

Partition Equal Subset Sum

MEDIUM
Amazon
Adobe

74.

Minimum number of jumps to reach end

HARD
Amazon
Google
Ebay

75.

Interleaving String

HARD
Google
Microsoft
Yahoo

76.

Coin change problem

MEDIUM
Microsoft

77.

Edit distance Problem

HARD
Amazon
Google
Microsoft

78.

Min Cost Path

MEDIUM
Amazon

79.

Maximal Square

MEDIUM
Google
Microsoft

80.

Longest Arithmetic Progression

MEDIUM
Google
Microsoft

81.

Word break problem

HARD
Facebook
Google

82.

Maximum Subarray Sum

MEDIUM
Amazon
Microsoft
Yahoo
Facebook

83.

Palindrome Partitioning

HARD
Amazon
Google

84.

Max Product Subarray

MEDIUM
Amazon
Microsoft

85.

Maximum Product of Three Numbers

MEDIUM
Amazon

86.

Gas station Problem

MEDIUM
Amazon
Google

87.

Distribute Candy Problem

EASY
Amazon
Microsoft

88.

Fractional Knapsack problem

MEDIUM
Amazon

89.

Sudoku Solver

HARD
Amazon
Google
Microsoft

90.

Generate Parentheses

MEDIUM
Facebook
Microsoft

91.

Print all subset

MEDIUM
Amazon
Microsoft
Facebook

92.

Combination Sum

MEDIUM
Amazon
Facebook
Adobe

93.

Combinations

MEDIUM
Amazon
Adobe

94.

Letter Combinations of a Phone Number

HARD
Google

95.

Word ladder problem

MEDIUM
Google
Microsoft
Ebay

96.

Smallest Multiple With 0 and 1

HARD
Amazon

97.

Check loop in array according to given constraints

MEDIUM
Google
Amazon

98.

Course Schedule

HARD
Amazon

99.

Knight on chessboard

HARD
Amazon
Goldman Sachs

100.

Surrounded regions

HARD
Google