Hello guys, if you are preparing for your next Programming Job interview and looking for some frequently asked Coding or Programming questions to practice then you have come to the right place. In this article, I am going to share some of the most commonly asked Coding questions from Programming Job interviews. In order to do well on the Coding interview you need practice, you just can't go there and try to solve the coding problems in limited time, that's actually one of the most common reasons to fail your programming Job interviews. Sometimes, the interviewer also asks little bit easier coding questions on a telephonic interview like revering array in place or reversing a string in place.

Sometimes, when you hear these popular coding questions first time on the interview, you stumble because of nervousness and lack of preparation and that's where knowledge of popular coding questions is important before going for any programming job interviews.

Most of the coding questions are based upon data structures like an array, string, linked list, binary tree, etc, but sometimes you also get algorithmic, tricky, logical and scenario based questions like how to swap two integers without using a temp variable or how to check if two rectangles overlap on each other or not.

That's why I have divided this list of coding problems into five categories, I mean

Btw, good knowledge of Data Structure and Algorithm is essential and even though you will learn a lot of new concepts by solving these questions, I suggest you first refresh your knowledge of Data Structure and Algorithm before attempting these questions by joining a comprehensive course like

There is no point in attempting these questions if you don't have sufficient knowledge of data structure and Algorithms.

##

Here is my list of some of the most popular coding questions to crack any programming job interviews.

The questions are more like you find in the popular book Cracking the Coding Interview by Gayle Lakmann Mcdowell, one of the essential books to do well on a Job interview, but more focus on Data Structure and Coding rather than touching every single possible topic required for a programming job interview like SQL, UNIX, Database, Networking, etc, for that, you need to read books and you can find many good titles here.

We'll start the list by first exploring array based questions e.g. finding pairs whose sum is given a number and then move to string-based questions,

##

If you ask me just one topic to prepare really well for coding interviews, I would pick the array. It's one of the essential data structure and favorite darling of coding interviews. There are so many popular coding interview questions which are based upon the array, some of them are easy and some are tough but you can be sure that you will see some questions based upon array in your next programming job interview.

If you don't know, an array is a data structure which holds other objects like String, int, float, etc. It holds them in a

Insertion and deletion of an array are tough because you cannot change the size of an array once created and you need to create a new array and copy elements from old to new.

Anyway, here are some of the

2. How to find the duplicate number on a given integer array? (solution)

4. How to find all pairs of integer array whose sum is equal to a given number? (solution)

6. How to remove duplicates from a given array in Java? (solution)

7. How to sort an integer array in place using QuickSort algorithm? (solution)

9. How to reverse an array in place in Java? (solution)

I have linked to all the solution but you should try to solve them by yourself before looking at the solution, especially if you have time. That's the only sure way to learn to programme by solving these coding questions.

If you find these questions difficult to solve then once again I suggest you to first refresh your knowledge of fundamental data structures like an array by going through a comprehensive course. If you need recommendations,

If you think these 10 questions from the array is not enough and you are interested in solving more array-based programming problems then you can also check out this 30 array based coding questions for more practice.

##

After array, String is the next popular topic on Programming job interviews, but if you have a good understanding of array then you can easily deal with String programming questions because String is nothing but a character array.

The string is implemented differently in a different programming language like in C it's a NULL terminated character array but in Java, it's an object. Though, you can still get access to the underlying array to apply your logic.

Here is a list of some of the frequently asked coding questions which are based on String. Though some of them are quite old, you can still expect this in your programming job interview:

12. How to check if two Strings are anagrams of each other? (solution)

14. How to reverse a given String using recursion? (solution)

16. How to find duplicate characters in a String? (solution)

18. How to count the occurrence of a given character in String? (solution)

20. How to reverse words in a given sentence without using any library method? (solution)

21. How to check if two String is a rotation of each other? (solution)

Similar to an array, I have also linked to a solution for all of these String problems but if you want to get most of this article, you better solve these questions without looking at the answers. Only when you stuck and running out-of-time, you can look at the solution.

And, if you find these frequently asked String problems difficult to solve, maybe it's time to go back to the drawing board and learn the fundamentals of String data structure again. If you need resources then

You can also learn from it by comparing your solution with the solution I have given. It's not necessarily to be the same but you can learn a lot by comparing them and if you need more practice, here is another list of 20 String algorithm questions.

##

Along with array and string, a linked list is another popular data structure in the programming world as well as on coding interviews. You will find a lot of questions on a linked list like reversing a linked list, adding a new element, removing an element from the middle, etc.

It's also the counterpart of an array data structure. While array stores elements on contiguous memory location, the linked list stored them at different locations and find them by storing there address. a linked list is made of nodes, an internal data structure which holds the value as well as the address of the next node.

Because of its structure, it's easier to add and remove elements from the linked list like on O(1) time if you are adding or removing from the head but the search is equally difficult and takes O(n) time, as you have to literally walk through each element.

Anyway, here is a collection of some of the simple and tricky linked list based coding question for your practice:

24. How to check if a given linked list contains cycle? How to find the starting node of the cycle? (solution)

25. How to reverse a linked list? (solution)

27. How to remove duplicate nodes in an unsorted linked list? (solution)

28. How to find the length of a singly linked list? (solution)

30. How do you find the sum of two linked list using Stack? (program)

Similar to array and string, I have also linked to all the solutions but you should only look them once you solved the problem on your own or you feel stuck.

A key to solving linked list is a good understanding of

That was the case with me as well but after practice and visualizing how recursion really works, I overcome that deficiency. If you are on the same boat, I strongly suggest you go through a visual course like

Once you understand recursion, most of the linked list based problems have an easy recursive solution than their iterative version. And if you need more practice, here is another list of 30 linked list programming questions for your reference.

##

A tree is another popular data structure in the programming world and coding interviews. Unlike array and linked list, which are considered linear data structure, a tree is considered a hierarchical data structure and used to arrange information in hierarchical order.

There are a lot of different types of tree e.g. a binary tree, binary search tree, AVL tree, Red Black tree, etc but Binary and Binary search tree are also known as BST are two of the most popular ones and most of the question are based upon them.

Some questions are also based upon theoretical knowledge of tree data structure e.g. finding the height of the tree, finding leaf nodes, checking if the tree is balanced or not, etc, hence you should also spend some time to learn the basics, along with practicing coding questions.

Anyway, here is a list of a popular binary tree and binary search tree based coding question to practice before your job interview:

31. How do you perform Pre-order traversal in a given binary tree? (solution)

33. How to perform an In order traversal in given binary tree? (solution)

35. How to implement Post-order traversal algorithm? (solution)

37. How to Print all leaves of a binary search tree? (solution)

39. How to perform a binary search in a given array? (solution)

Like an array, linked list and string questions, I have also linked to all solution for binary tree questions but you should only look them once you have tried it yourself.

One trick I would like to share with you while solving tree questions is to remember that, similar to a linked list, the tree is also a recursive data structure and most of the tree based problems has an easy recursive solution.

For example, a subtree is also a tree which means you can apply the same steps to subtree can devise a recursive solution. In the above list, many popular tree algorithms e.g. pre-order, post-order, in-order are implemented recursively as well as iterative.

If you don't feel confident to solve these problems and want to refresh your knowledge of binary tree and other data structure before attempting these questions, then you should check out

##

Even though data structure based questions makes the bulk of Coding Interview, there are always some questions from topics like sorting algorithms, bit manipulation, software design, Dynamic Programming, and other logical and tricky questions.

In this list below, you will find most of the common searching and sort questions as well as a couple of design and bit manipulation questions.

41. How to implement Iterative QuickSort Algorithm? (solution)

43. How to implement Merge Sort Algorithm? (solution)

44. How to implement the Bucket Sort Algorithm? (solution)

46. How to implement Radix Sort Algorithm? (solution)

47. How to swap two numbers without using the third variable? (solution)

48. How to check if two rectangles overlap with each other? (solution)

50. How to implement an LRU Cache in your favorite programming language? (solution)

51. How to check if a given number is a Palindrome? (solution)

52. How do you check if a given number is an Armstrong number? (solution)

54. How do check if a given number is positive or negative in Java? (solution)

55. How to find the largest prime factor of a given integral number? (solution)

56. Write a Program to print all prime numbers up to a given number? (solution)

58. Write a Program to print Pascal's triangle? (solution)

59. How to calculate the square root of a given number? (solution)

61. How to implement the Sieve of Eratosthenes Algorithm? (solution)

62. How to add two numbers without using the plus operator in Java? (solution)

63. Write a Program to subtract two binary numbers? (solution)

65. Write a Program to add or subtract two Matrices? (solution)

66. Write a Program to multiply two Matrices in Java? (solution)

68. How to check if a given number is even/odd without using Arithmetic operator? (solution)

69. Write a Program to find GCD of two numbers using Euclid's Algorithm? (solution)

71. Write a Program to given Pyramid structure? (solution)

72. How to find the highest repeating world from a given file in Java? (solution)

74. How to convert a decimal number to binary in Java? (solution)

Like previous topics, I have provided links to a solution but you should only look them once you tried to solve the questions yourself. That's important for learning.

That's all about some of the

Once you have gone through all these coding questions, you can not only solve them when you see them in the interview but also develop the coding sense and problem-solving ability which will help you to solve new and slightly modified versions of these questions on real programming interview.

Though, if you are not in a rush and want to hone your coding skill further, here are some more resources to practice questions

Some

Thanks a lot for reading this article so far. If you like these Coding Interview questions then please share with your friends and colleagues. If you have any questions or feedback then please drop a note.

Sometimes, when you hear these popular coding questions first time on the interview, you stumble because of nervousness and lack of preparation and that's where knowledge of popular coding questions is important before going for any programming job interviews.

Most of the coding questions are based upon data structures like an array, string, linked list, binary tree, etc, but sometimes you also get algorithmic, tricky, logical and scenario based questions like how to swap two integers without using a temp variable or how to check if two rectangles overlap on each other or not.

That's why I have divided this list of coding problems into five categories, I mean

**array based coding questions**, string-based questions, linked list questions, binary tree questions, and others miscellaneous questions, where you will find questions on bit manipulation, design, tricky, logical and other miscellaneous topics.Btw, good knowledge of Data Structure and Algorithm is essential and even though you will learn a lot of new concepts by solving these questions, I suggest you first refresh your knowledge of Data Structure and Algorithm before attempting these questions by joining a comprehensive course like

**Data Structures and Algorithms: Deep Dive Using Java**on Udemy.There is no point in attempting these questions if you don't have sufficient knowledge of data structure and Algorithms.

##
__Top 50 Coding Interview Questions for Programmers__

Here is my list of some of the most popular coding questions to crack any programming job interviews.The questions are more like you find in the popular book Cracking the Coding Interview by Gayle Lakmann Mcdowell, one of the essential books to do well on a Job interview, but more focus on Data Structure and Coding rather than touching every single possible topic required for a programming job interview like SQL, UNIX, Database, Networking, etc, for that, you need to read books and you can find many good titles here.

We'll start the list by first exploring array based questions e.g. finding pairs whose sum is given a number and then move to string-based questions,

**linked list based questions**, binary tree questions and finally tackler other topics.##
__1. Array-based Programming Interview Questions __

If you ask me just one topic to prepare really well for coding interviews, I would pick the array. It's one of the essential data structure and favorite darling of coding interviews. There are so many popular coding interview questions which are based upon the array, some of them are easy and some are tough but you can be sure that you will see some questions based upon array in your next programming job interview.If you don't know, an array is a data structure which holds other objects like String, int, float, etc. It holds them in a

**contiguous location in memory**which makes it easily searchable and retrieval in O(1) time using the index.Insertion and deletion of an array are tough because you cannot change the size of an array once created and you need to create a new array and copy elements from old to new.

Anyway, here are some of the

**most popular array based coding interview questions**for your preparation:**1. How to find the missing number in given integer array of 1 to 100?**(solution)2. How to find the duplicate number on a given integer array? (solution)

**3. How to find the largest and smallest number in an unsorted integer array?**(solution)4. How to find all pairs of integer array whose sum is equal to a given number? (solution)

**5. How to find duplicate numbers in an array if it contains multiple duplicates?**(solution)6. How to remove duplicates from a given array in Java? (solution)

7. How to sort an integer array in place using QuickSort algorithm? (solution)

**8. How to remove duplicates from an array in place?**(solution)9. How to reverse an array in place in Java? (solution)

**10. How to find multiple missing numbers in given integer array with duplicates?**(solution)I have linked to all the solution but you should try to solve them by yourself before looking at the solution, especially if you have time. That's the only sure way to learn to programme by solving these coding questions.

If you find these questions difficult to solve then once again I suggest you to first refresh your knowledge of fundamental data structures like an array by going through a comprehensive course. If you need recommendations,

**Algorithms and Data Structures Part 1**and Part 2 by Robert Horvick are two of the best course to start with. You will also learn about Big(O) notation and how to calculate time and space complexity.If you think these 10 questions from the array is not enough and you are interested in solving more array-based programming problems then you can also check out this 30 array based coding questions for more practice.

##
__2. String-based Coding Interview Questions__

After array, String is the next popular topic on Programming job interviews, but if you have a good understanding of array then you can easily deal with String programming questions because String is nothing but a character array.The string is implemented differently in a different programming language like in C it's a NULL terminated character array but in Java, it's an object. Though, you can still get access to the underlying array to apply your logic.

Here is a list of some of the frequently asked coding questions which are based on String. Though some of them are quite old, you can still expect this in your programming job interview:

**11. How to Print duplicate characters from String?**(solution)12. How to check if two Strings are anagrams of each other? (solution)

**13. How to print first non repeated character from String?**(solution)14. How to reverse a given String using recursion? (solution)

**15. How to check if a String contains only digits?**(solution)16. How to find duplicate characters in a String? (solution)

**17. How to count a number of vowels and consonants in a given String?**(solution)18. How to count the occurrence of a given character in String? (solution)

**19. How to find all permutations of String?**(solution)20. How to reverse words in a given sentence without using any library method? (solution)

21. How to check if two String is a rotation of each other? (solution)

**22. How to check if given String is Palindrome?**(solution)Similar to an array, I have also linked to a solution for all of these String problems but if you want to get most of this article, you better solve these questions without looking at the answers. Only when you stuck and running out-of-time, you can look at the solution.

And, if you find these frequently asked String problems difficult to solve, maybe it's time to go back to the drawing board and learn the fundamentals of String data structure again. If you need resources then

**Data Structures and Algorithms Specialization**on Coursera is one of the best online resources you can use to make your foundations rock solid.You can also learn from it by comparing your solution with the solution I have given. It's not necessarily to be the same but you can learn a lot by comparing them and if you need more practice, here is another list of 20 String algorithm questions.

##
__3. Linked list based Programming Interview Questions__

Along with array and string, a linked list is another popular data structure in the programming world as well as on coding interviews. You will find a lot of questions on a linked list like reversing a linked list, adding a new element, removing an element from the middle, etc.It's also the counterpart of an array data structure. While array stores elements on contiguous memory location, the linked list stored them at different locations and find them by storing there address. a linked list is made of nodes, an internal data structure which holds the value as well as the address of the next node.

Because of its structure, it's easier to add and remove elements from the linked list like on O(1) time if you are adding or removing from the head but the search is equally difficult and takes O(n) time, as you have to literally walk through each element.

Anyway, here is a collection of some of the simple and tricky linked list based coding question for your practice:

**23. How to find the middle element of a singly linked list in one pass?**(solution)24. How to check if a given linked list contains cycle? How to find the starting node of the cycle? (solution)

25. How to reverse a linked list? (solution)

**26. How to reverse a singly linked list without recursion?**(solution)27. How to remove duplicate nodes in an unsorted linked list? (solution)

28. How to find the length of a singly linked list? (solution)

**29. How to find the 3rd node from the end in a singly linked list?**(solution)30. How do you find the sum of two linked list using Stack? (program)

Similar to array and string, I have also linked to all the solutions but you should only look them once you solved the problem on your own or you feel stuck.

A key to solving linked list is a good understanding of

**recursion**because a linked list is a naturally recursive data structure, for example, if you take one node out of the linked list, the result is another linked list, but many programmers struggle to understand recursion.That was the case with me as well but after practice and visualizing how recursion really works, I overcome that deficiency. If you are on the same boat, I strongly suggest you go through a visual course like

**Visualizing Data Structures and Algorithms in Java**to learn Recursion and data structure. That will help you a lot in your thought process and problem-solving skill.Once you understand recursion, most of the linked list based problems have an easy recursive solution than their iterative version. And if you need more practice, here is another list of 30 linked list programming questions for your reference.

##
__4. Binary Tree based Coding Interview Questions__

A tree is another popular data structure in the programming world and coding interviews. Unlike array and linked list, which are considered linear data structure, a tree is considered a hierarchical data structure and used to arrange information in hierarchical order.There are a lot of different types of tree e.g. a binary tree, binary search tree, AVL tree, Red Black tree, etc but Binary and Binary search tree are also known as BST are two of the most popular ones and most of the question are based upon them.

Some questions are also based upon theoretical knowledge of tree data structure e.g. finding the height of the tree, finding leaf nodes, checking if the tree is balanced or not, etc, hence you should also spend some time to learn the basics, along with practicing coding questions.

Anyway, here is a list of a popular binary tree and binary search tree based coding question to practice before your job interview:

**30. Can you write a program to implement a binary search tree?**(solution)31. How do you perform Pre-order traversal in a given binary tree? (solution)

**32. Write a Program to traverse a given binary tree in Pre-order without recursion**(solution)33. How to perform an In order traversal in given binary tree? (solution)

**34. How to print all nodes of given binary tree using inorder traversal without recursion**(solution)35. How to implement Post-order traversal algorithm? (solution)

**36. How to traverse a binary tree in Post order traversal without recursion**(solution)37. How to Print all leaves of a binary search tree? (solution)

**38. How to count a number of leaf nodes in a given binary tree?**(solution)39. How to perform a binary search in a given array? (solution)

Like an array, linked list and string questions, I have also linked to all solution for binary tree questions but you should only look them once you have tried it yourself.

One trick I would like to share with you while solving tree questions is to remember that, similar to a linked list, the tree is also a recursive data structure and most of the tree based problems has an easy recursive solution.

For example, a subtree is also a tree which means you can apply the same steps to subtree can devise a recursive solution. In the above list, many popular tree algorithms e.g. pre-order, post-order, in-order are implemented recursively as well as iterative.

If you don't feel confident to solve these problems and want to refresh your knowledge of binary tree and other data structure before attempting these questions, then you should check out

**Data Structures and Algorithms: Deep Dive Using Java**from Udemy.##
__5. Miscellaneous Programming Interview Questions__

Even though data structure based questions makes the bulk of Coding Interview, there are always some questions from topics like sorting algorithms, bit manipulation, software design, Dynamic Programming, and other logical and tricky questions.In this list below, you will find most of the common searching and sort questions as well as a couple of design and bit manipulation questions.

**40. How to implement the Bubble Sort algorithm?**(solution)41. How to implement Iterative QuickSort Algorithm? (solution)

**42. How to implement Insertion Sort Algorithm?**(solution)43. How to implement Merge Sort Algorithm? (solution)

44. How to implement the Bucket Sort Algorithm? (solution)

**45. How to implement the Counting Sort Algorithm?**(solution)46. How to implement Radix Sort Algorithm? (solution)

47. How to swap two numbers without using the third variable? (solution)

48. How to check if two rectangles overlap with each other? (solution)

**49. How to design a Vending Machine?**(solution)50. How to implement an LRU Cache in your favorite programming language? (solution)

51. How to check if a given number is a Palindrome? (solution)

52. How do you check if a given number is an Armstrong number? (solution)

**53. How do find all prime factors of a given number?**(solution)54. How do check if a given number is positive or negative in Java? (solution)

55. How to find the largest prime factor of a given integral number? (solution)

56. Write a Program to print all prime numbers up to a given number? (solution)

**57. Write a Program to print Floyd's triangle?**(solution)58. Write a Program to print Pascal's triangle? (solution)

59. How to calculate the square root of a given number? (solution)

**60. How to check if the given number is a prime number?**(solution)61. How to implement the Sieve of Eratosthenes Algorithm? (solution)

62. How to add two numbers without using the plus operator in Java? (solution)

63. Write a Program to subtract two binary numbers? (solution)

**64. Write a Program to transpose a Matrix?**(solution)65. Write a Program to add or subtract two Matrices? (solution)

66. Write a Program to multiply two Matrices in Java? (solution)

**67. How to calculate the average of all numbers in a given array?**(solution)68. How to check if a given number is even/odd without using Arithmetic operator? (solution)

69. Write a Program to find GCD of two numbers using Euclid's Algorithm? (solution)

**70. How to find the number of 1s (the Set bit) in a given Bit Sequence?**(solution)71. Write a Program to given Pyramid structure? (solution)

72. How to find the highest repeating world from a given file in Java? (solution)

**73. How to reverse given Integer in Java?**(solution)74. How to convert a decimal number to binary in Java? (solution)

**75. How to check if a given year is a leap year in Java?**(solution)Like previous topics, I have provided links to a solution but you should only look them once you tried to solve the questions yourself. That's important for learning.

That's all about some of the

**essential Programming and Coding Interview questions**to crack any programming Job interviews. This list covers the most important topics like an array, string, linked list, binary tree, and several others.Once you have gone through all these coding questions, you can not only solve them when you see them in the interview but also develop the coding sense and problem-solving ability which will help you to solve new and slightly modified versions of these questions on real programming interview.

Though, if you are not in a rush and want to hone your coding skill further, here are some more resources to practice questions

Some

**Useful Resources**for Coding Interviews- Data Structures in Java: An Interview Refresher
- 10 Data Structure, Algorithms, and Programming Courses to Crack Interviews
- 10 Algorithms Books Every Programmer should Read
- 10 Free Courses to Learn Data Structure and Algorithms in Depth
- LeetCode - The Programming Interview Platform
- 10 Courses to Prepare for Programming Job Interviews
- 50+ Data Structure and Algorithms Problems from Interviews
- How to design Vending Machine in Java
- 100+ Coding Interview Questions for Programmers
- 5 Free Courses to Learn Algorithms for Interviews
- 10 Books to Prepare Technical Programming/Coding Job Interviews

Thanks a lot for reading this article so far. If you like these Coding Interview questions then please share with your friends and colleagues. If you have any questions or feedback then please drop a note.

**P.S. -**As I have said before, good knowledge of data structure and algorithms is the most important thing to do well on interviews and if you feel that you have forgotten those concepts or want to fill gaps in your understanding, here are some useful list of books and courses to learn Data Structure and Algorithms.
disappointing way to start an otherwise useful article: "hey guys..."

ReplyDeleteas a female SE, "hey guys..." feels like a careless and exclusionary introduction. if it was nestled into the body of the article, I probably wouldn't notice. However, as the first thing I read, my first thought is to comment, and then close immediately. no jokes here, I'm merely stating that I'm unlikely to be the only female engineer sensitive to this in the tech industry.

ReplyDeleteI say "hey guys..." in much the same way a southerner says "ya'll", it's just a plural for a group. Stop turning everything into a problem.

DeleteYeah, about time, I change my style and start saying "Hello all", thanks a lot.

DeleteSorry, I didn't mean that. It's just my casual way to start the article. I very much appreciate woman in tech and female software engineer. About time, I change my style to say "Hello All" instead of of "Hello Guys". Thanks

DeleteSorry, I didn't mean that. It's just my casual way to start the article. I very much appreciate woman in tech and female software engineer. About time, I change my style to say "Hello All" instead of of "Hello Guys". Thanks

ReplyDeleteHey feminist, it is just a word. Really you are going to get offended and discount everything that the page says because of one word? A real strong woman would move past it and realize the interview questions included within are actually quite good and detailed and probably will prepare you quite well for a job interview. Instead you are so concerned about the word "guys" at the top. Did you ever notice how actual guys don't spend time worrying about trivial things and just focus on getting the job done. Try that instead.

ReplyDeleteAll the lady engineers who get help from male engineers should remember to give back. Time and again, my experience with female engineers at conferences has been very poor. There is no sharing of knowledge. It cannot be one way street in the name of equality.

ReplyDeleteTwo, please respect the author who works for the whole community, rather than nit-picking over political correctness.

Three, have courage to post a comment like this with your own signature, not anonymously. :-)

Oh please, if you respected women in the industry, you wouldn't be so critical of them. I agree with the poster. The terminology should be more inclusive. It's a matter of respect.

Deleteomg, you fight each other just for "hello guys" words ?

ReplyDeleteVery useful..Thanks..!!

ReplyDelete