100 Data Structures and Algorithms Problems Asked During Coding Interviews

Amit Shekhar
AfterAcademy
Published in
5 min readDec 4, 2019

I am Amit Shekhar, Co-Founder @ Outcome School, I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.

New content: System Design Playlist

Here, I have listed the 100 Data Structures and Algorithms Problems asked during the coding interviews in companies like Amazon, Microsoft, Facebook, LinkedIn, Adobe, Uber, Yahoo, eBay, etc.

Practice problems and never give up!

Let’s become friends on Twitter, Linkedin, Github, Quora, and Facebook.

Let’s get started with the questions.

  1. Roman To Integer

Asked in: Amazon, Microsoft, Facebook

2. Reverse Bits

Asked in: Amazon

3. Square Root of Integer

Asked in: Amazon, Microsoft, Facebook

4. Calculate power function

Asked in: Google, LinkedIn, Amazon

5. Greatest Common Divisor

Asked in: Google

6. Find the Closest Palindrome

Asked in: Microsoft, Amazon

7. Rotate matrix

Asked in: Google

8. Spiral Matrix

Asked in: Microsoft, Amazon

9. Wave Array

Asked in: Amazon, Google, Adobe

10. Set Matrix Zeroes

Asked in: Amazon, Google

11. maximum j — i such that A[j] > A[i]

Asked in: Google, Amazon, Adobe

12. Move zeroes to an end

Asked in: Facebook, Uber

13. Merge two sorted arrays

Asked in: Microsoft, Adobe

14. Container with Most Water

Asked in: Amazon, Google, Facebook, Adobe

15. Remove duplicates from sorted array

Asked in: Amazon, Microsoft, Google

16. Find an element in Bitonic array

Asked in: Amazon

17. Find minimum element in sorted and rotated array

Asked in: Facebook

18. Median of two sorted array of same size

Asked in: Amazon, Microsoft, Google

19. Inversion count in an array

Asked in: Amazon, Google

20. Search for a Range in a sorted array

Asked in: Microsoft, Google

21. Longest Common Prefix

Asked in: Amazon, Google

22. Median in row wise sorted matrix

Asked in: Amazon

23. Swap List Nodes in pairs

Asked in: Amazon, Microsoft

24. Add Two Numbers as Lists

Asked in: Amazon, Microsoft, Facebook

25. Check if a singly linked list is palindrome

Asked in: Amazon, Microsoft

26. Reverse a linked list from position m to n

Asked in: Amazon, Microsoft, Facebook

27.Detect and Remove Loop in a Linked List

Asked in: Amazon, Microsoft

28. Merge Two Sorted Lists

Asked in: Amazon, Microsoft, Yahoo

29. Remove Nth Node from List End

Asked in: Amazon

30. Sort a linked list using insertion sort

Asked in: Microsoft, Google

31. Find next greater element in an array

Asked in: Amazon, Microsoft

32. Trapping rain water

Asked in: Amazon, Google

33. Merge overlapping intervals

Asked in: Amazon, Google

34. Largest Rectangle in Histogram

Asked in: Amazon, Google, Facebook

35. Check for balanced parentheses in an expression

Asked in: Amazon, Microsoft

36. Min Stack Problem

Asked in: Amazon, Microsoft, Yahoo, Adobe

37. LRU Cache implementation

Asked in: Amazon, Microsoft, Adobe, Google

38. Sort a stack using another stack

Asked in: Amazon, Microsoft

39. Lowest Common Ancestor of a Binary tree

Asked in: Amazon, Google, Microsoft, Facebook, Adobe

40. Path sum in binary tree

Asked in: Amazon, Microsoft, Yahoo

41. Min Depth of Binary Tree

Asked in: Amazon, Facebook

42. Binary Tree Zigzag Level Order Traversal

Asked in: Amazon, Microsoft

43. Invert Binary Tree

Asked in: Amazon, Google

44. Flatten Binary Tree to Linked List

Asked in: Amazon, Microsoft, Yahoo, Adobe

45. Find diameter of binary tree

Asked in: Facebook, Google, Amazon

46. All Nodes Distance K in Binary Tree

Asked in: Microsoft

47. Merge two binary tree

Asked in: Amazon, Microsoft

48. Shortest Unique Prefix

Asked in: Google

49. Sorted Array To Balanced BST

Asked in: Amazon

50. K-th largest element in BST

Asked in: Amazon

51. Minimum absolute difference in BST

Asked in: Google

52. Recover Binary Search Tree

Asked in: Amazon, Microsoft

53. Merge Two BST

Asked in: Google, Amazon, Microsoft

54. Lowest Common Ancestor of a BST

Asked in: Amazon, Microsoft

55. K Pairs with Smallest Sums

Asked in: Google

56. Sliding window maximum

Asked in: Amazon, Google

57. Merge K sorted list

Asked in: Amazon, Google

58. Convert a min heap to max heap

Asked in: Google

59. Check if two arrays are equal or not

Asked in: Amazon, Goldman Sachs

60. Intersection of two unsorted array

Asked in: Google, Facebook

61. Longest Consecutive Sequence

Asked in: Amazon, Google

62. Valid Anagram

Asked in: Google, Amazon, Microsoft

63. Majority Element

Asked in: Amazon, Microsoft, Yahoo, Google

64. Sort Characters by Frequency

Asked in: Facebook, Google

65. First Unique Character in a String

Asked in: Amazon, Microsoft

66. Triplet with zero sum

Asked in: Facebook, Amazon, Microsoft

67. First missing positive

Asked in: Amazon

68. Largest subarray with 0 sum

Asked in: Microsoft

69. Max points on the straight line

Asked in: Amazon, Google

70. Climbing Stairs Problem

Asked in: Amazon, Google

71. Matrix Chain Multiplication

Asked in: Amazon, Microsoft

72. Longest Increasing subsequence

Asked in: Amazon, Microsoft, Facebook

73. Partition Equal Subset Sum

Asked in: Amazon, Adobe

74. Minimum number of jumps to reach end

Asked in: Amazon, Google, eBay

75. Interleaving String

Asked in: Google, Microsoft, Yahoo

76. Coin change problem

Asked in: Microsoft

77. Edit distance Problem

Asked in: Amazon, Google, Microsoft

78. Min Cost Path

Asked in: Amazon

79. Maximal Square

Asked in: Google, Microsoft

80. Longest Arithmetic Progression

Asked in: Google, Microsoft

81. Word break problem

Asked in: Facebook, Google

82. Maximum Subarray Sum

Asked in: Amazon, Microsoft, Yahoo, Facebook

83. Palindrome Partitioning

Asked in: Amazon, Google

84. Max Product Subarray

Asked in: Amazon, Microsoft

85. Maximum Product of Three Numbers

Asked in: Amazon

86. Gas station Problem

Asked in: Amazon, Google

87. Distribute Candy Problem

Asked in: Amazon, Microsoft

88. Fractional Knapsack problem

Asked in: Amazon

89. Sudoku Solver

Asked in: Amazon, Google, Microsoft

90. Generate Parentheses

Asked in: Facebook, Microsoft

91. Print all subset

Asked in: Amazon, Microsoft, Facebook

92. Combination Sum

Asked in: Amazon, Facebook, Adobe

93. Combinations

Asked in: Amazon, Adobe

94. Letter Combinations of a Phone Number

Asked in: Google

95. Word ladder problem

Asked in: Google, Microsoft, eBay

96. Smallest Multiple With 0 and 1

Asked in: Amazon

97. Check loop in array according to given constraints

Asked in: Google, Amazon

98. Course Schedule

Asked in: Amazon

99. Knight on chessboard

Asked in: Amazon, Goldman Sachs

100. Surrounded regions

Asked in: Google

Bonus:

What is System Design? A Beginner-Friendly Introduction

Thanks for reading.

Prepare yourself for Android Interview: Android Interview Questions

You can find the Roadmap for Android Developer here: Android Developer Roadmap

Thanks

Amit Shekhar

Co-Founder @ Outcome School

Let’s become friends on Twitter, Linkedin, Github, Quora, and Facebook.

Clap, share if you like it and follow me for the updates.

--

--

Amit Shekhar
AfterAcademy

Co-Founder @ Outcome School | Coder | Teacher | Mentor | Open Source | IIT 2010-14 | Android | Machine Learning | Backend