DEV Community

Cover image for 101 Coding Problems and few Tips to Crack Your Next Programming Interviews

101 Coding Problems and few Tips to Crack Your Next Programming Interviews

javinpaul profile image javinpaul ・20 min read

Disclosure: This post includes affiliate links; I may receive compensation if you purchase products or services from the different links provided in this article.

Coding Interviews are such an important thing in a programmer's life that he just can't get away with that. It's the first hurdle they need to cross to get the software developer job they wish throughout their school and college days.

To make the matter worse, you will find that so many people on the internet telling that coding interview is flawed, the hiring process for programmers sucks and so on but you don't need to pay attention to them, not at least at the start of your career.

They may be right but they are inside the train which you are trying to get into. No matter, how much they criticize the coding interviews and programmers' hiring process, many of them have gone through the same route to where they are.

We all know that Coding Interview System is not perfect and many are trying to change it but until it's changed, you got to follow its rules to get into the System. This is something for experience developers to deal with, as a junior developer your priority should be to clear the coding interview and get the job you want.

As an author of a Java blog and a Medium publication, I receive a lot of queries related to coding problems and how to deal with them and that's why I keep writing articles like this which have helped a lot of programmers directly and in-directly in their career.

In this article, I am going to share with you top 101 coding interview problems from programming job interviews which every programmer should know.

What to prepare for Coding Interviews?

Now that, I have cleared the confusion that Coding Interview is important and you should not distract, let's get into real work. The big question is what to prepare for Coding interviews?

Well, the most important thing to prepare is Data Structure-based coding problems like array-based coding problems, string problems, linked list problems, binary tree problems, system design problems etc.

Apart from data structure-based questions, most of the programming job interviews also ask algorithm, design, bit manipulation, and general logic-based questions, which I'll describe in this section.

It's important that you practice these concepts because sometimes they become tricky to solve in the actual interview. Having practiced them before not only makes you familiar with them but also gives you more confidence in explaining the solution to the interviewer.

One of the main problems with coding problems is that there are hundreds and thousands of coding problems on interviews, there are even sites like LeetCode, HackerRank, Codewars, Topcoder, freeCodeCamp, HackerEarth which train programmers for coding interviews with lots of tough questions, which sometimes just overwhelms a beginner looking for a job.

I believe in simplicity and the 10% of effort which produces 90% of results and that's why I have collected top 101 coding problems which are not too tough and also frequently asked on real interviews.

Solving these problems not only gives you confidence but also help you to recognize some of the most common algorithmic patterns which will also help you to solve some unseen problems on real interviews.

Essential Resources for Coding Interviews

The selection of good resources is very important for success in your coding interviews. If you chose a wrong resource then more than money, you will lose valuable time you need for preparation, hence spend some time researching for good resources.

If you need recommendations, following are some of my the tried and tested resources to learn Data Structure and Algorithms in-depth for coding interviews:

This is like the meta course for coding interviews, which will not teach you how to solve a coding problem but, instead, teach you how to solve a particular type of coding problems using patterns. Master these 15 underlying patterns to interview questions, and you'll be able to tackle anything you face on the interview

And, if you prefer books, there is no better than the Cracking The Coding Interview, by Gayle Laakmann McDowellwhich presents 189+ Programming questions and solution. A good book to prepare for programming job interviews in a short time. Btw, I will also earn some money if you buy any of these resources mentioned here.

Important Tips for Coding Interviews and Getting a Job

  1. There is no better way to do well in Coding interviews than practicing as many coding problems as possible. This will not only train your mind to recognize algorithmic patterns in problems but also give you the much-needed confidence to solve the problem you have never seen before.

  2. My second tips are to learn about as many data structure and algorithms as possible. This is an extension of the previous tip but it also involves reading and not just practicing. For example, If you know about the hash table you can also many array and counter-based problems easily. Same is true for tree and graph.

  3. Choosing the right data structure is a very important part of software development and coding interview and unless and until you know them, you won't be able to choose.

  4. Time yourself --- candidates who solve interview problems within the time limit and quickly are more likely to do well in the interview so you should also time yourself.

  5. Think of edge cases and run your code through them. Some good edge cases might be the empty input, some weird input or some really large input to test the boundary conditions and limits.

  6. After solving the problem, try explaining it to a friend or colleagues how is also interested in coding problems. This will tell you whether you have really understood the problem or not. If you can explain easily means you understood. Also, the discussion makes your mind work and you could come up with an alternative solution and able to find some flaws in your existing algorithms.

  7. Another useful tip to excel Coding interviews is to appear in the coding interview and lots of them. You will find yourself getting better after every interview and this also helps you to get multiple offers which further allows you to better negotiate and get those extra 30K to 50K which you generally leave on a table if you just have one offer in hand.

  8. Btw, If you are ready for Coding Interview then you can also take TripleByte's quiz and go directly to the final round of interviews with top tech companies like Coursera, Adobe Acrobat, Dropbox, Grammarly, Uber, Quora, Evernote, Twitch, and many more.

I didn't know about Triplebyte before, but they are providing a great service to job seekers. A big thanks to them.

100 programming interview questions of last 5 years

Top 101 Coding Problems from Programming Job interviews

Without wasting any more of your time, here is my list of 101 frequently asked coding problems from programming job interviews. In order to get most of this list, I suggest to actually solve the problem.

Do it yourself, no matter whether you stuck because that's the only way to learn. After solving a couple of problems you will gain confidence. I also suggest you look at the solution when you stuck or after you have solved the problem, this way you learn to compare different solution and how to approach a problem from a different angle.

  1. How is a bubble sort algorithm implemented? (solution)
  2. How is a merge sort algorithm implemented? (solution)
  3. How do you count the occurrence of a given character in a string? (solution)
  4. How do you print the first non-repeated character from a string? (solution)
  5. How do you convert a given String into int like the atoi()? (solution)
  6. How do you implement a bucket sort algorithm? (solution)
  7. How do you implement a counting sort algorithm? (solution)
  8. How do you remove duplicates from an array in place? (solution)
  9. How do you reverse an array in place in Java? (solution)
  10. How are duplicates removed from an array without using any library? (solution)
  11. How is a radix sort algorithm implemented? (solution)
  12. How do you swap two numbers without using the third variable? (solution)
  13. How do you check if two rectangles overlap with each other? (solution)
  14. How do you design a vending machine? (solution)
  15. How do you find the missing number in a given integer array of 1 to 101? (solution)
  16. How do you find the duplicate number on a given integer array? (solution)
  17. How do you find duplicate numbers in an array if it contains multiple duplicates? (solution)
  18. Difference between a stable and unstable sorting algorithm? (answer)
  19. How is an iterative quicksort algorithm implemented? (solution)
  20. How do you find the largest and smallest number in an unsorted integer array? (solution)
  21. How do you reverse a linked list in place? (solution)
  22. How to add an element at the middle of the linked list? (solution)
  23. How do you sort a linked list in Java? (solution)
  24. How do you find all pairs of an integer array whose sum is equal to a given number? (solution)
  25. How do you implement an insertion sort algorithm? (solution)
  26. How are duplicates removed from a given array in Java? (solution)
  27. how to remove the duplicate character from String? (solution)
  28. How to find the maximum occurring character in given String? (solution)
  29. How is an integer array sorted in place using the quicksort algorithm? (solution)
  30. How do you reverse a given string in place? (solution)
  31. How do you print duplicate characters from a string? (solution)
  32. How do you check if two strings are anagrams of each other? (solution)
  33. How do you find all the permutations of a string? (solution)
  34. How can a given string be reversed using recursion? (solution)
  35. How do you check if a given string is a palindrome? (solution)
  36. How do you find the length of the longest substring without repeating characters? (solution)
  37. Given string str, How do you find the longest palindromic substring in str? (solution)
  38. How do you check if a string contains only digits? (solution)
  39. How to remove Nth Node from the end of a linked list? (solution)
  40. How to merge two sorted linked list? (solution)
  41. How to convert a sorted list to a binary search tree? (solution)
  42. How do you find duplicate characters in a given string? (solution)
  43. How do you count a number of vowels and consonants in a given string? (solution)
  44. How do you reverse words in a given sentence without using any library method? (solution)
  45. How do you check if two strings are a rotation of each other? (solution)
  46. How to convert a byte array to String? (solution)
  47. How do you remove a given character from String? (solution)
  48. How do you find the middle element of a singly linked list in one pass? (solution)
  49. How do you check if a given linked list contains a cycle? How do you find the starting node of the cycle? (solution)
  50. How do you reverse a linked list? (solution)
  51. How do you reverse a singly linked list without recursion? (solution)
  52. How are duplicate nodes removed in an unsorted linked list? (solution)
  53. How do you find the length of a singly linked list? (solution)
  54. How do you find the third node from the end in a singly linked list? (solution)
  55. How do you find the sum of two linked lists using Stack? (solution)
  56. What is the difference between array and linked list? (answer)
  57. How to remove duplicates from a sorted linked list? (solution)
  58. How to find the node at which the intersection of two singly linked lists begins. (solution)
  59. Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. (solution)
  60. How to check if a given linked list is a palindrome? (solution)
  61. How to remove all elements from a linked list of integers which matches with given value? (solution)
  62. How is a binary search tree implemented? (solution)
  63. How do you perform preorder traversal in a given binary tree? (solution)
  64. How do you traverse a given binary tree in preorder without recursion? (solution)
  65. How do you perform an inorder traversal in a given binary tree? (solution)
  66. How do you print all nodes of a given binary tree using inorder traversal without recursion? (solution)
  67. How do you implement a postorder traversal algorithm? (solution)
  68. How do you traverse a binary tree in postorder traversal without recursion? (solution)
  69. How are all leaves of a binary search tree printed? (solution)
  70. How do you count a number of leaf nodes in a given binary tree? (solution)
  71. How do you perform a binary search in a given array? (solution)
  72. How to Swap two numbers without using the third variable? (solution)
  73. How to check if two rectangles overlap with each other? (solution)
  74. How to design a Vending Machine? (solution)
  75. How to implement an LRU Cache in your favorite programming language? (solution)
  76. How to check if a given number is a Palindrome? (solution)
  77. How to check if a given number is an Armstrong number? (solution)
  78. How to find all prime factors of a given number? (solution)
  79. How to check if a given number is positive or negative in Java? (solution)
  80. How to find the largest prime factor of a given integral number? (solution)
  81. How to print all prime numbers up to a given number? (solution)
  82. How to print Floyd's triangle? (solution)
  83. How to print Pascal's triangle? (solution)
  84. How to calculate the square root of a given number? (solution)
  85. How to check if the given number is a prime number? (solution)
  86. How to add two numbers without using the plus operator in Java? (solution)
  87. How to check if a given number is even/odd without using Arithmetic operator? (solution)
  88. How to print a given Pyramid structure? (solution)
  89. How to find the highest repeating world from a given file in Java? (solution)
  90. How to reverse given Integer in Java? (solution)
  91. How to convert a decimal number to binary in Java? (solution)
  92. How to check if a given year is a leap year in Java? (solution)
  93. Can you implement a Binary search Algorithm without recursion? (solution)
  94. Difference between a stable and unstable sorting algorithm? (answer)
  95. What is Depth First Search Algorithm for a binary tree? (solution)
  96. How is an iterative quicksort algorithm implemented? (solution)
  97. How do you implement an insertion sort algorithm? (solution)
  98. How is a merge sort algorithm implemented? (solution)
  99. What is the difference between Comparison and Non-Comparison Sorting Algorithms? (answer)
  100. How do implement Sieve of Eratosthenes Algorithms for Prime Number? (solution)
  101. How to find sub array with maximum sum? (solution)

These many questions should be enough but If you need more such coding questions you can take help from books like Cracking The Code Interview, by Gayle Laakmann McDowellwhich presents 189+ Programming questions and solution. A good book to prepare for programming job interviews in a short time.

Now, You're Ready for the Coding Interview

These are some of the most common questions outside of data structure and algorithms that help you to do really well in your interview.

I have also shared a lot of these questions on my blog, so if you are really interested, you can always go there and search for them.

These common coding, data structure, and algorithm questions are the ones you need to know to successfully interview with any company, big or small, for any level of programming job.

If you are looking for a programming or software development job in 2019, you can start your preparation with this list of coding questions and if you ready for Interview then you can also take TripleByte's quiz and go directly to the final round of interviews with top tech companies like Coursera, Adobe, Dropbox, Grammarly, and many more.

This list provides good topics to prepare and also helps assess your preparation to find out your areas of strength and weakness.

Good knowledge of data structure and algorithms is important for success in coding interviews and that's where you should focus most of your attention.

Further Learning
Data Structures and Algorithms: Deep Dive Using Java
10 Books to Prepare Technical Programming/Coding Job Interviews
10 Algorithm Books Every Programmer Should Read
Top 5 Data Structure and Algorithm Books for Java Developers
From 0 to 1: Data Structures & Algorithms in Java
Data Structure and Algorithms Analysis --- Job Interview
20+ String based coding problems from interviews
20+ linked list problems from interviews
20+ basic algorithms based problems from interviews

Closing Notes

Thanks, You made it to the end of the article ... Good luck with your programming interview! It's certainly not going to be easy, but by following this searching and sorting algorithm questions, you are one step closer than others. By the way, the more questions you solve in practice, the better your preparation will be.

So, if you think 101 coding problems are not enough and you need more, then check out these additional 50 programming questions for telephone interviews and these books and courses for more thorough preparation.

All the best for your coding interview.

Discussion (10)

Editor guide
shivamrawat0l profile image
Shivam Rawat
  • promotion detected *
aminmansuri profile image

How is bubble sort implemented?

Don't implement it, use insertion sort instead for quick and dirty implementations.

Its hard to believe that people still try to hire this way. It rarely achieves the purpose you're aiming for.

eljayadobe profile image

I have interviewed about a hundred people.

Yes, I'm one of those scoundrels that presents a coding interview.

I look for two things in a coding interview: technical competence, and character assessment.

The number one thing that a candidate can do to immediately ruin their chances: try to lie or attempt to baffle me with bulldoodoo. I've got a very good BS detector.

So if you are interviewing, and you don't know something, say "I don't know." It's hard to do, especially in an interview. But an "I don't know" is not necessarily a strike against you. Whereas BS is a disqualifier.

joydeeep profile image

Thanks for sharing this post...!
Check this site as well:
This site is very up-to-date with the latest interview question and for that matter there are alot of top tech companies interview questions covered.

e4emre profile image

When I was interviewing, I didn't look for the candidate who knew everything, I looked for the people who could think about new concepts, come up with new solutions to problems they haven't encountered before. Anyone can memorize and spit out some lines of code. If you want top talent, you have to see how they fail. So I go the extra mile... I ask increasingly difficult and obscure questions until I reach the interviewee's limit of knowledge. At that point the pass or fail can be determined by looking at how they respond to their own failure:
A. they don't know but they try to hide their lack of knowledge.
B. they don't know and just admit they don't know.
C. they admit not knowing and continue with "here's how I think it might work" and are genuinely curious as to what the solution is. This one is the winner.

Don't just memorize bunch of code. Learn how to approach problems you never encountered before. Granted, most interviewers aren't like me. Most interviewers usually just ask if you're good at regurgitating an algorithm and that's all that matters to them. You pass the interview if one of the algorithms you memorized is the one that they asked. That's why the software industry is full of copy & paste engineers who can do a fine job of applying existing solutions to problems but can't think themselves out of a paper bag when they encounter novel problems.

bitpunchz profile image

Pretty cool article :D

I made a course a couple of months ago that received decent feedback, might be worth taking a look at the structure and let me know what you think ;) :

doodg profile image
Mahmoud Hesham

Thank you for all these tips and for the great article 😊😊

mrinaldi2 profile image

So this article is about let us know that you are able to collect some links on internet and promote yourself ? What if you focus more on the reader and less on you ?

blanchart profile image
Francisco Blanchart

Thanks a lot for taking your time in this investigation labour. A great resource.

harshrathod50 profile image
Harsh Rathod

This is such a resourceful article. 😇