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 expect to solve the coding problems in limited time. Sometimes, the interviewer also asks little bit easier coding questions on telephonic interview e.g. 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 asked for Data Structures e.g. array, string, linked list, binary tree etc, but sometimes you also get algorithmic, tricky, logical and scenario based questions e.g. swapping two integers without using a temp variable or checking if two rectangle overlap or not.

That's why I have divided this list into five categories i.e.

A 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. If you need resources, you can check this list of books and courses to learn 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 popular book Cracking for Job Interview, 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 programming job interview e.g. 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 e.g 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 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 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

###

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 different programming language e.g. 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 in 2018.

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. You can also learn from it by comparing your solution with the solution I have given. It's not necessarily to be same but you can learn a lot by comparing them and if you need more practice, here is another list of

###

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

It's also the counterpart of 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 next node.

Becuase of its structure, it's easier to add and remove elements from the linked list e.g. 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 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.

This means most of the linked list based problems has 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. 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 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 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 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 same steps to subtree can devise a recursive solution. In 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 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 a 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 Sieve of Eratosthenes Algorithm? (solution)

62. How to add two numbers without using 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

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

Some

Data Structures and Algorithms: Deep Dive Using Java

Preparing for Job Interview by John Sonmez

Cracking the Coding Interview: 189 Programming Questions and Solutions

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. - If you have any doubt over questions or you need more details, you can always ask us by dropping 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 asked for Data Structures e.g. array, string, linked list, binary tree etc, but sometimes you also get algorithmic, tricky, logical and scenario based questions e.g. swapping two integers without using a temp variable or checking if two rectangle overlap or not.

That's why I have divided this list into five categories i.e.

**array based coding questions**, string-based questions, linked list questions, binary tree questions and others where we'll tackle bit manipulation, design, tricky, logical and other miscellaneous topics.A 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. If you need resources, you can check this list of books and courses to learn 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 popular book Cracking for Job Interview, 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 programming job interview e.g. 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 e.g 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 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 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 different programming language e.g. 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 in 2018.

**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. You can also learn from it by comparing your solution with the solution I have given. It's not necessarily to be 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 programming world as well as on coding interviews. You will find a lot of questions on linked list e.g. reversing a linked list, adding a new element, removing an element from middle etc.It's also the counterpart of 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 next node.

Becuase of its structure, it's easier to add and remove elements from the linked list e.g. 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 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.

This means most of the linked list based problems has 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. 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 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 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 given binary tree?**(solution)39. How to perform a binary search in 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 same steps to subtree can devise a recursive solution. In 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 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 Bucket Sort Algorithm? (solution)

**45. How to implement 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 a 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 given number is a prime number?**(solution)61. How to implement Sieve of Eratosthenes Algorithm? (solution)

62. How to add two numbers without using 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 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 most important topics e.g. 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 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 and Algorithms: Deep Dive Using Java

Preparing for Job Interview by John Sonmez

Cracking the Coding Interview: 189 Programming Questions and Solutions

10 Books to Prepare Technical Programming/Coding Job Interviews

10 Courses to Prepare for Programming Job Interviews

LeetCode - The Programming Interview Platform

The Coding Interview Bootcamp: Algorithms + Data Structures

LeetCode - The Programming Interview Platform

The Coding Interview Bootcamp: Algorithms + Data Structures

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. - If you have any doubt over questions or you need more details, you can always ask us by dropping a note.

## No comments:

## Post a Comment