101 Coding Problems and few Tips to Crack Your Next Programming Interviews
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:
Data Structures and Algorithms: Deep Dive Using Java for Java developers. Learn about Arrays, Linked Lists, Trees, Hashtables, Stacks, Queues, Heaps, Sort algorithms and Search algorithms
Algorithms and Data Structures in Python for those who love Python\
A guide to implementing the most up to date algorithms from scratch: arrays, linked lists, graph algorithms, and sortingJavaScript Algorithms and Data Structures Masterclassby Colt_Steele for JavaScript programmers. The Missing Computer Science and Coding Interview Bootcamp. Learn everything you need to ace difficult coding interviews.
Mastering Data Structures & Algorithms using C and C++ for those who are good at C/C++
Data Structures in Java: An Interview Refresher by The Educative Teamto refresh important Data Structure and algorithms concepts in Java. This course contains a detailed review of all the common data structures and provides implementation level details in Java to allow readers to become well equipped.
Grokking the Coding Interview: Patterns for Coding Questionsby Fahim ul Haq and The Educative Team\
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
- How is a bubble sort algorithm implemented? (solution)
- How is a merge sort algorithm implemented? (solution)
- How do you count the occurrence of a given character in a string? (solution)
- How do you print the first non-repeated character from a string? (solution)
- How do you convert a given String into int like the atoi()? (solution)
- How do you implement a bucket sort algorithm? (solution)
- How do you implement a counting sort algorithm? (solution)
- How do you remove duplicates from an array in place? (solution)
- How do you reverse an array in place in Java? (solution)
- How are duplicates removed from an array without using any library? (solution)
- How is a radix sort algorithm implemented? (solution)
- How do you swap two numbers without using the third variable? (solution)
- How do you check if two rectangles overlap with each other? (solution)
- How do you design a vending machine? (solution)
- How do you find the missing number in a given integer array of 1 to 101? (solution)
- How do you find the duplicate number on a given integer array? (solution)
- How do you find duplicate numbers in an array if it contains multiple duplicates? (solution)
- Difference between a stable and unstable sorting algorithm? (answer)
- How is an iterative quicksort algorithm implemented? (solution)
- How do you find the largest and smallest number in an unsorted integer array? (solution)
- How do you reverse a linked list in place? (solution)
- How to add an element at the middle of the linked list? (solution)
- How do you sort a linked list in Java? (solution)
- How do you find all pairs of an integer array whose sum is equal to a given number? (solution)
- How do you implement an insertion sort algorithm? (solution)
- How are duplicates removed from a given array in Java? (solution)
- how to remove the duplicate character from String? (solution)
- How to find the maximum occurring character in given String? (solution)
- How is an integer array sorted in place using the quicksort algorithm? (solution)
- How do you reverse a given string in place? (solution)
- How do you print duplicate characters from a string? (solution)
- How do you check if two strings are anagrams of each other? (solution)
- How do you find all the permutations of a string? (solution)
- How can a given string be reversed using recursion? (solution)
- How do you check if a given string is a palindrome? (solution)
- How do you find the length of the longest substring without repeating characters? (solution)
- Given string str, How do you find the longest palindromic substring in str? (solution)
- How do you check if a string contains only digits? (solution)
- How to remove Nth Node from the end of a linked list? (solution)
- How to merge two sorted linked list? (solution)
- How to convert a sorted list to a binary search tree? (solution)
- How do you find duplicate characters in a given string? (solution)
- How do you count a number of vowels and consonants in a given string? (solution)
- How do you reverse words in a given sentence without using any library method? (solution)
- How do you check if two strings are a rotation of each other? (solution)
- How to convert a byte array to String? (solution)
- How do you remove a given character from String? (solution)
- How do you find the middle element of a singly linked list in one pass? (solution)
- How do you check if a given linked list contains a cycle? How do you find the starting node of the cycle? (solution)
- How do you reverse a linked list? (solution)
- How do you reverse a singly linked list without recursion? (solution)
- How are duplicate nodes removed in an unsorted linked list? (solution)
- How do you find the length of a singly linked list? (solution)
- How do you find the third node from the end in a singly linked list? (solution)
- How do you find the sum of two linked lists using Stack? (solution)
- What is the difference between array and linked list? (answer)
- How to remove duplicates from a sorted linked list? (solution)
- How to find the node at which the intersection of two singly linked lists begins. (solution)
- 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)
- How to check if a given linked list is a palindrome? (solution)
- How to remove all elements from a linked list of integers which matches with given value? (solution)
- How is a binary search tree implemented? (solution)
- How do you perform preorder traversal in a given binary tree? (solution)
- How do you traverse a given binary tree in preorder without recursion? (solution)
- How do you perform an inorder traversal in a given binary tree? (solution)
- How do you print all nodes of a given binary tree using inorder traversal without recursion? (solution)
- How do you implement a postorder traversal algorithm? (solution)
- How do you traverse a binary tree in postorder traversal without recursion? (solution)
- How are all leaves of a binary search tree printed? (solution)
- How do you count a number of leaf nodes in a given binary tree? (solution)
- How do you perform a binary search in a given array? (solution)
- How to Swap two numbers without using the third variable? (solution)
- How to check if two rectangles overlap with each other? (solution)
- How to design a Vending Machine? (solution)
- How to implement an LRU Cache in your favorite programming language? (solution)
- How to check if a given number is a Palindrome? (solution)
- How to check if a given number is an Armstrong number? (solution)
- How to find all prime factors of a given number? (solution)
- How to check if a given number is positive or negative in Java? (solution)
- How to find the largest prime factor of a given integral number? (solution)
- How to print all prime numbers up to a given number? (solution)
- How to print Floyd's triangle? (solution)
- How to print Pascal's triangle? (solution)
- How to calculate the square root of a given number? (solution)
- How to check if the given number is a prime number? (solution)
- How to add two numbers without using the plus operator in Java? (solution)
- How to check if a given number is even/odd without using Arithmetic operator? (solution)
- How to print a given Pyramid structure? (solution)
- How to find the highest repeating world from a given file in Java? (solution)
- How to reverse given Integer in Java? (solution)
- How to convert a decimal number to binary in Java? (solution)
- How to check if a given year is a leap year in Java? (solution)
- Can you implement a Binary search Algorithm without recursion? (solution)
- Difference between a stable and unstable sorting algorithm? (answer)
- What is Depth First Search Algorithm for a binary tree? (solution)
- How is an iterative quicksort algorithm implemented? (solution)
- How do you implement an insertion sort algorithm? (solution)
- How is a merge sort algorithm implemented? (solution)
- What is the difference between Comparison and Non-Comparison Sorting Algorithms? (answer)
- How do implement Sieve of Eratosthenes Algorithms for Prime Number? (solution)
- 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.
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.
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.
Thank you for all these tips and for the great article 😊😊
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 ?
This is such a resourceful article. 😇