coding problem solving interview questions

100+ Coding Interview Questions for Programmers and Software Engineers in 2024

Solve these frequently asked coding problems to do well on your next programming job interviews..

codeburst

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 the top 100 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 interviews 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, 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 produce 90% of results and that’s why I have collected top 100 coding problems which are not too tough and also frequently asked on real interviews.

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

Best Resources for Coding Interviews

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

If you need recommendations, the 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

Data Structures and Algorithms: Deep Dive Using Java

So you've worked with the basics of data structures and algorithms in java (or another oo programming language) but….

  • 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 sorting

Algorithms and Data Structures in Python

This course is about data structures and algorithms. we are going to implement the problems in python. i highly….

  • JavaScript Algorithms and Data Structures Masterclass by Colt_Steele for JavaScript programmers. The Missing Computer Science and Coding Interview Bootcamp. Learn everything you need to ace difficult coding interviews.

JavaScript Algorithms and Data Structures Masterclass

This course crams months of computer science and interview prep material into 20 hours of video. the content is based….

  • 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 Team to 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 Questions by 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 problem using patterns. Master these 15 underlying patterns to interview questions, and you’ll be able to tackle anything you face on the interview

Grokking the Coding Interview: Patterns for Coding Questions

Coding interviews are getting harder every day. a few years back, brushing up on key data structures and going through….

www.educative.io

System Design is another topic which is quite important for coding interviews and when it comes to System design , there are not many places where you can learn System design concepts and architecture in depth, but ByteByteGo is exceptional.

ByteByteGo | Ace Your Next System Design Interview

Everything you need to take your system design skill to the next level.

bytebytego.com

It’s one of those sites where I have learned a lot. They explain many key System design concept like Microservices , load balancing, caching, Algorithms like CAP theorem and how to design a particular system with easily digestible diagram. It’s created by Alex Xu, author of System Design Interview — An insider’s guide , one of the best System Design book , and I highly recommend this to everyone preparing for coding interviews.

System Design Interview - An insider's guide

Buy system design interview - an insider's guide on amazon.com ✓ free shipping on qualified orders.

www.amazon.com

And, if you prefer books, there is no better than the Cracking The Coding Interview , by Gayle Laakmann McDowell which presents 189+ Programming questions and solutions. 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.

5 Best Tips to Crack Coding Interviews in 2023

Here are a few of my practical tips to crack your next coding interview. These are hard-earned and I learned from my own mistakes and experience.

  • 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 problems 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. The same is true for trees and graphs.
  • 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 colleague 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 be able to find some flaws in your existing algorithms.
  • Another useful tip to excel in 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.

Triplebyte: Software Engineer Job Search

Take a quiz. get offers from multiple top tech companies at once..

triplebyte.com

Top 100 Coding Problems from Programming Job interviews

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

Do it yourself, no matter whether you are 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 are stuck or after you have solved the problem, this way you learn to compare different solutions 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 100? ( 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 a 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 lists? (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 the 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 the 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 a 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 )
  • What is Depth First Search Algorithm for a binary tree? (solution)
  • What is the difference between Comparison and Non-Comparison Sorting Algorithms? ( answer )
  • How do implement Sieve of Eratosthenes Algorithms for Prime Number? ( 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 McDowell which presents 189+ Programming questions and solutions. 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 any company, big or small, for any level of programming job.

If you are looking for a programming or software development job in 2024, you can start your preparation with this list of coding questions and if you are ready for an 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 ByteByteGo for System Design and Architecture

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 these 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 100 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.

Other Articles you may like:

Top 10 Free Data Structure and Algorithms Courses for Beginners — Best of Lot

Algorithms and data structure are two of the most fundamentals and essential topics from computer science, which is…, 10 best books for data structure and algorithms for beginners in java, c/c++, and python, algorithms are language agnostic, and any programmer worth their salt should be able to convert them to code in their…, my favorite free courses to learn data structures and algorithms in depth, by javinpaul data structures and algorithms are some of the most essential topics for programmers, both to get a job….

www.freecodecamp.org

codeburst

Written by javinpaul

I am Java programmer, blogger, working on Java, J2EE, UNIX, FIX Protocol. I share Java tips on http://javarevisited.blogspot.com and http://java67.com

More from javinpaul and codeburst

The 2024 Software Architect or Solution Architect RoadMap

Javarevisited

The 2024 Software Architect or Solution Architect RoadMap

An illustrated guide to becoming a software architect in 2024 with links to relevant courses.

How To Create Horizontal Scrolling Containers

How To Create Horizontal Scrolling Containers

As a front end developer, more and more frequently i am given designs that include a horizontal scrolling component. this has become….

Top 50 Java Interview Questions for Beginners and Junior Developers

Top 50 Java Interview Questions for Beginners and Junior Developers

A list of frequently asked java questions and answers from programming job interviews of java developers of different experience..

best  System Design Interview Books

Top 10 System Design Interview Books in 2024

My favorite books and courses system design interviews in 2024, recommended from medium.

I Solved 300+ Leetcode problems , Here is what I learnt.

I Solved 300+ Leetcode problems , Here is what I learnt.

Uber and Google interview experience 2024

Ankit Pahwa

Uber and Google interview experience 2024

Short into about me.

coding problem solving interview questions

General Coding Knowledge

coding problem solving interview questions

Coding & Development

coding problem solving interview questions

Stories to Help You Grow as a Software Developer

coding problem solving interview questions

Predictive Modeling w/ Python

Advice From a Software Engineer With 8 Years of Experience

Benoit Ruiz

Better Programming

Advice From a Software Engineer With 8 Years of Experience

Practical tips for those who want to advance in their careers.

Java 8 Interview Questions for 10 Years Experience

AKCoding.com

Java 8 Interview Questions for 10 Years Experience

Java 8 interview questions for 10 years experience, the interview questions will likely delve deeper into java 8 features, advanced….

Cisco Java Developer Interview Transcript 2024(Java,Spring-Boot,Hibernate)

Ajay Rathod

Cisco Java Developer Interview Transcript 2024(Java,Spring-Boot,Hibernate)

“hello folks, i am jotting down the full tech interview round for a java developer position at cisco. all these q&a are actual questions….

Roadmap to Learn AI in 2024

Benedict Neo

bitgrit Data Science Publication

Roadmap to Learn AI in 2024

A free curriculum for hackers and programmers to learn ai.

Text to speech

22 Coding Interview Questions Every Developer Should Know

HackerRank AI Promotion

Coding tests have been the backbone of technical hiring for decades. If you’re a web developer, programmer, or engineer on the job market, your ability to demonstrate your skills in a coding interview is critical to landing your next role. 

The key to succeeding in these interviews is preparing well for the styles of problems you might encounter. In this post, we’ll break down four categories of coding interview questions you could face — and 22 sample questions to help you start preparing.

Web Developer Interview Questions: An Overview

Coding interview questions  — sometimes called coding challenges — ask developers to write code to find an answer to a problem. Depending on the role and company, coding questions can be language-specific or allow developers to respond in their coding language of choice. Often, these questions are asked directly via an in-browser IDE that  provides developers with the tools they need  to provide a solution in full.

While coding questions come in a variety of formats, the strategies for answering them are similar. As you write your code, you’ll be expected to explain your solution to the hiring team. They’ll typically give you real-time feedback on the efficacy, complexity, and accuracy of your solution.

It’s important to keep in mind that a “correct” answer isn’t always enough to pass a coding interview. That’s because the approach also allows hiring teams to assess your technical communication, your code quality, and the efficiency of the solution.

Examples of coding tests include: 

  • Take-home tests sent during screening
  • Multiple-choice tests
  • Project-based tests 
  • Pair-programming in a virtual IDE

This part of the process is highly variable, with hiring managers able to choose from a number of formats on how to evaluate technical skills. Programmers will need to carefully prepare to ensure they can adapt to a variety of challenges.

Types of Coding Interview Questions

There are a number of different types of coding questions employers can use to evaluate a programmer’s coding skills. The difficulty and composition of these tests will vary based on the experience-level of the role. 

Generally, the more experienced a developer is, the more ambiguous and challenging the questions they will be asked. For example, candidates for entry-level roles might complete coding questions that test execution of predefined problems. In contrast, questions for senior roles can become more open-ended, writing code for problems without predefined solutions. 

The following is a list of the types of coding questions a programmer might encounter during a technical interview.

Algorithm questions are foundational to the technical interview. They test a candidate’s coding skills and ability to solve problems with algorithms in a programming language of their choice.

Sample Question : The Efficient Janitor

The janitor of a high school is extremely efficient. By the end of each day, all of the school’s waste is in plastic bags weighing between 1.01 pounds and 3.00 pounds. All plastic bags are then taken to the trash bins outside. One trip is described as selecting a number of bags which together do not weigh more than 3.00 pounds, dumping them in the outside trash can and returning to the school. Given the number of plastic bags, and the weights of each bag, determine the minimum number of trips the janitor has to make.

This problem tests the candidate’s ability to use two pointers to search for pairs in an assorted array.

More algorithm coding questions:

  • Given an array of integers, find the sum of its elements. For example, if ar = [1, 2, 3] , 1 + 2 + 3 = 6. So, return 6.
  • Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix ar = [1, 2, 3, 4, 5, 6 , 7, 8, 9 ], arranged in a 3×3 grid resembling a phone keypad.
  • You are in charge of the cake for a child’s birthday. You have decided the cake will have one candle for each year of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are tallest. For example, in the array candles = [4, 4, 1, 3] , return 2.
  • Given a time in 12-hour AM/PM format, convert it to 24-hour military time. 12:00:00AM on a 12-hour clock is 00:00:00 on a 24-hour clock. 12:00:00PM on a 12-hour clock is 12:00:00 on a 24-hour clock. For example, if s = 12:01:00AM , return 00:01:00 .

Data Structures

Data structures are a fundamental concept of computer science and any programming language. Essential for algorithmic design, programmers use data structures for the efficient organization and modification of data.

Sample Question: Binary Search Tree

You are given a pointer to the root of a binary search tree and values to be inserted into the tree. Insert the values into their appropriate position in the binary search tree and return the root of the updated binary tree. You just have to complete the function.

A binary search tree is a rooted binary tree data structure with internal nodes that each store a key less than all the keys in its right subtree and greater than all the keys in the node’s left subtree.

This question tests a programmer’s ability to work with data structures to solve problems.

More data structure questions:

  • Delete the node at a given position in a linked list and return a reference to the head node. The head is at position 0.
  • You are given the pointer to the head node of a linked list and an integer to add to the list. Create a new node with the given integer. Insert this node at the tail of the linked list and return the head node of the linked list formed after inserting this new node. The given head pointer may be null, meaning that the initial list is empty.
  • Given a pointer to the head node of a linked list, print each node’s  element, one per line. If the head pointer is null (indicating the list is empty), there is nothing to print.
  • A linked list is said to contain a cycle if any node is visited more than once while traversing the list. Given a pointer to the head of a linked list, determine if it contains a cycle. If it does, return 1. Otherwise, return 0.

An array is a data structure containing elements identified by one or more indexes or keys. Arrays are a fundamental data structure, making them a favorite of interviewers looking to test programmers coding skill. Because the size of an array can’t change, solving this style of question requires finding the optimal way to either rearrange or copy the array into the correct result.

Sample Question: Automated Cutting Machine

An automated cutting machine is used to cut rods into segments. The cutting machine can only hold a rod of minLength or more. A rod is marked with the necessary cuts and their lengths are given as an array in the order they are marked. Determine if it is possible to plan the cuts so the last cut is from a rod at least minLength units long.

This problem tests a programmer’s ability to use arrays, along with loops and greedy algorithms. It requires the programmer to come up with an algorithm to check if an array of given lengths of the rod can be cut from left and right exactly n – 1 time and the remaining size of the rod is at least minLength in a constrained time and space complexity.

More array coding questions:

  • Write a program to check if two arrays are equal.
  • How do you find the smallest and largest numbers in an unsorted array? 
  • There is a collection of input strings and a collection of query strings. For each query string, determine how many times it occurs in the list of input strings. Return an array of the results.
  • A left rotation operation on an array of size n shifts each of the array’s elements unit to the left. Given an integer, d , rotate the array that many steps left and return the result.
  • Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each the array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in the array.

Language-Specific Problems

Most coding questions aren’t specific to a particular programming language, allowing a programmer to write code in their language of choice. However, some coding interviews will have questions that test a specific language required by the role.

Sample Question: Enhanced Flexible Grid

Languages: JavaScript, CSS

Create a flexible grid with 1 row and 4 columns. The width of each column is 25% of the window size. This percentage width must be maintained even if the page is resized. Each cell of the grid can contain another 1×4 flexible grid. The border of the grid must be 1px black.

Perform the following operations based on the value of window size:

  • If the window size is less than 720px, then the 1×4 flexible grid becomes a 2×2 grid. That is, the 3rd and 4th columns slide down onto the 2nd row.
  • If the window size is less than 360px, then the 1×4 flexible grid becomes 4×1 grid. Each column slides under the one before it. The 2nd column slides under the 1st, the 3rd slides under the 2nd, and the 4th slides under the 3rd.

This question tests a developer’s ability to write code in JS and CSS and build UI elements. Essential to responsive design, a flexible grid tests a candidate’s ability to perform a task required by a role in front-end development.

More language-specific coding questions:

  • A hacker practices on HackerRank until getting to a rating of O(1) read as (Oh-one) . Call the method coder.practice until coder.oh_one? becomes true. Use the until control structure. until is the logical equivalent of while not. This challenge has a one-line answer. (Language: Ruby)
  • Write a function int max_of_four(int a, int b, int c, int d) which reads four arguments and returns the greatest of them. There is not a built-in max function in C. Code that will be reused is often put in a separate function, e.g. int max(x, y) that returns the greater of the two values. Input will contain four integers – a, b, c, d – one on each line. Note: I/O will be automatically handled. (Language: C)
  • The opening tags follow the format: <tag-name attribute1-name = “value1” attribute2-name = “value2” …>.   
  • The closing tags follow the format: </tag-name> . 
  • The attributes are referenced as: tag1~value, tag1.tag2~name
  • Given the source code in HRML format consisting of N lines, answer Q queries. For each query, print the value of the attribute specified. Print “Not Found!” if the attribute does not exist.
  • If n is odd, print Weird
  • If n is even and in the inclusive range of 2 to 5, print Not Weird
  • If n is even and in the inclusive range of 6 to 20, print Weird
  • If n is even and greater than 20, print Not Weird
  • Input format: a single line containing a positive integer n. Constraints: 1 <= n <= 100.
  • (Language: Java)

Resources to Prepare for Web Developer Interviews

HackerRank for Developers

15 Common Problem-Solving Interview Questions

Software Engineering Questions to Know in 2022

7 System Design Interview Questions Every Software Engineer Should Know

What Does a Software Developer Do? Role Overview and Skill Expectations

Get started with HackerRank

Over 2,500 companies and 40% of developers worldwide use HackerRank to hire tech talent and sharpen their skills.

Recommended topics

  • Coding Questions
  • Interview Preparation

Abstract, futuristic image generated by AI

6 REST API Interview Questions Every Developer Should Know

Top techniques to approach and solve coding interview questions

The biggest fear most candidates will have during a coding interview is: what if I get stuck on the question and don't know how to do it? Fortunately, there are structured ways to approach coding interview questions that will increase your chances of solving them. From how to find a solution or approach, to optimizing time and space complexity, here are some of the top tips and best practices that will help you solve coding interview questions.

How to find solutions to coding interview problems ​

When given a coding interview question, candidates should start by asking clarifying questions and discussing a few possible approaches with their interviewers. However, this is where most candidates tend to get stuck. Thankfully, there are ways to do this in a structured manner.

Note that not all techniques will apply to every coding interview problem, and you can also use multiple techniques on one single problem! As you apply these techniques during your practice, you will develop the intuition for which technique will be useful for the problem at hand.

1. Visualize the problem by drawing it out ​

Ever wondered why coding interviews are traditionally done on whiteboards and videos explaining answers to coding questions tend to use diagrams? Whiteboards make it easy to draw diagrams which helps with problem solving! A huge part of coding is understanding how the internal state of a program changes and diagrams are super useful tools for representing the internal data structures state. If you are having a hard time understanding how the solution is obtained, come up with a visual representation of the problem and if necessary, the internal states at each step.

This technique is especially useful if the input involves trees, graphs, matrices, linked lists.

How would you return all elements of a matrix in spiral order ? Drawing out the matrix and the steps your iterator needs to take in each direction will help tremendously in allowing you to see the pattern.

2. Think about how you would solve the problem by hand ​

Solving the problem by hand is about solving the problem without writing any code, like how a non-programmer would. This already happens naturally most of the time when you are trying to understand the example given to you.

What some people don't realize is that sometimes a working solution is simply a code version of the manual approach. If you can come up with a concrete set of rules around the approach that works for every example, you can write the code for it. While you might not arrive at the most efficient solution by doing this, it's a start which will give you some credit.

How do you validate if a tree is a valid Binary Search Tree without writing any code? You first check if the left subtree contains only values less than the root, then check that the right subtree contains only values bigger than the root, then repeat for each node. This process seems feasible. Now you just have to turn this process into code.

3. Come up with more examples ​

Coming up with more examples is something useful you can do regardless of whether you are stuck or not. It helps you to reinforce your understanding of the question, prevents you from prematurely jumping into coding, helps you to identify a pattern which can be generalized to any input, which is the solution! Lastly, the multiple examples can be used as test cases at the end when verifying your solution.

4. Break the question down into smaller independent parts ​

If the problem is large, start with a high-level function and break it down into smaller constituting functions, solving each one separately. This prevents you from getting overwhelmed with the details of doing everything at once and keeps your thinking structured.

Doing so also makes it clear to the interviewer that you have an approach, even if you don't manage to finish coding all of the smaller functions.

The Group Anagrams problem can be broken down into two parts - hashing a string, grouping the strings together. Each part can be solved separately with independent implementation details. You could start off with this code:

And proceed to fill in the implementation of each function. However, do note that sometimes the most efficient solutions will require you to break some abstractions and do multiple operations in one pass of the input. If your interviewer asks you to optimize based on your well-abstracted solution, that is one possible path forward.

5. Apply common data structures and algorithms at the problem ​

Unlike real-world software engineering where the problems are usually open-ended and might not have clear solutions, coding interview problems tend to be smaller in nature and are designed to be solvable within the duration of the interview. You can also expect that the knowledge required to solve the problem is not out of this world and they would have been taught during college. Thankfully, the number of common data structures and algorithms is finite and a hacky approach which works from my experience is to try going through all the common data structures and applying them to the problem.

These are the data structures to keep in mind and try, in order of frequency they appear in coding interview questions:

  • Hash Maps : Useful for making lookup efficient. This is the most common data structure used in interviews and you are guaranteed to have to use it.
  • Graphs : If the data is presented to you as associations between entities, you might be able to model the question as a graph and use some common graph algorithm to solve the problem.
  • Stack and Queue : If you need to parse a string with nested properties (such as a mathematical equation), you will almost definitely need to use stacks.
  • Heap : Question involves scheduling/ordering based on some priority. Also useful for finding the max K/min K/median elements in a set.
  • Tree/Trie : Do you need to store strings in a space-efficient manner and look for the existence of strings (or at least part of them) very quickly?
  • Binary search: Useful if the input array is sorted and you need to do faster than O(n) searches
  • Sliding window
  • Two pointers
  • Traverse from the back
  • Topological Sorting

In future we will add tips on how to better identify the most relevant data structures and routines based on the problem.

How to optimize your approach or solution ​

After you've come up with an initial solution to the coding interview problem, your interviewer would most likely prompt you to optimize the solution by asking "Can we do better". The following techniques help you further optimize the time and space complexity of your solution:

How to optimize time complexity ​

1. identify the best theoretical time complexity of the solution ​.

The Best Theoretical Time Complexity (BTTC) of a solution is a time complexity you know that you cannot beat.

Some simplified examples:

  • The BTTC of finding the sum of numbers in array is O(n) because you have to look at every value in the array at least once
  • The BTTC of finding the number of groups of anagrams is O(nk) where n is the number of words and k is the maximum number of letters in a word because you have to look at each word at least once and look at each character in each word at least once
  • The BTTC of finding the number of islands in a matrix is O(nm) where n is the number of rows and m is the number of columns because you have to look at each cell in the matrix at least once

Why is it important to know the BTTC? So that you don't go down the rabbit hole of trying to find a solution that is faster than the BTTC. The fastest practical solution can only ever be as fast as the BTTC, not faster than the BTTC. The BTTC is not necessarily achievable in practice (hence theoretical), it just means you can never find a real solution that is faster than it. If your initial solution is slower than the BTTC, there could be opportunities to improve such that you can attain the BTTC (but not always the case). It wouldn't hurt to mention the BTTC to your interviewer, which will be taken as a positive signal and also to remind yourself that you should not try to come up with something faster than the BTTC.

Some people might think that the BTTC is simply the total number of elements in a data structure, because you need to go through each element once. This is not always true . The most famous example would be finding a number in a sorted array of numbers. The sorted property changes things a whole lot:

  • Finding a number would be O(log(n)) because you can use a binary search.
  • Finding the largest number would be O(1) because it is the last value in the array.

This is why it is important to pay attention to every detail given about the question. Be careful not to determine the incorrect BTTC due to lack of attention to the question details!

With the correct BTTC determined, you now know the time complexity of the optimal solution lies between your initial solution and the BTTC and can work your way towards it. If your solution already has the BTTC and the interviewer is asking you to optimize further, there are usually two things they are looking out for:

  • Do even less work. Your solution could be O(n) but making two passes of the array and the interviewer is looking for the solution that uses a single pass.
  • Use less space. Refer to the section below on optimizing space complexity.

2. Identify overlapping and repeated computation ​

A naive/brute force solution often executes the same operation over and over again. When the code is doing an expensive operation that has been done before, take a moment to step back and consider if you can reuse results from previous computations. Dynamic programming (DP) is the most obvious type of questions you can entirely leverage past computations. There are non-DP questions that can leverage this technique too, although not as straightforward and might require a preprocessing step.

The Product of Array Except Self question is a good example of a problem which contains overlapping/repeated work. To get the value for an index, you need to multiply the values at all other positions. Doing this for every value in the array would take O(n 2 ) time. However, see that:

  • result[n] : Product(nums[0] … nums[n-1]) * Product(nums[n + 1] … nums[N - 1])
  • result[n + 1] : Product(nums[0] … nums[n]) * Product(num[n + 2] … nums[N - 1])

There's a ton of duplicated work in computing the result[n] vs result[n + 1] ! This is an opportunity to reuse earlier computations made while computing result[n] to compute result[n + 1] . Indeed, we can make use of a prefix array to help us arrive at the final solution in O(n) time at the cost of more space.

3. Try different data structures ​

Choice of data structures is key to coding interviews. It can help you to reach a solution for the problem, it can also help you to optimize your existing solution. Sometimes it's worth going through the exercise of iterating through the data structures you know once again.

Is lookup time slowing your algorithm down? In general, most lookup operations should be O(1) with the help of a hash table. If the lookup operation in your solution is the bottleneck to your solution's time complexity, more often than not, you can use a hash table to optimize the lookup.

The K Closest Points to Origin question can be solved in a naive manner by calculating the distance of each point, sorting them and then taking the K smallest values. This takes O(nlog(n)) time because of the sorting. However, by using a Heap data structure, the time complexity can be reduced to O(nlog(k)) as adding/removing from the heap only takes O(log(k)) time when the size of the heap is capped at K elements. Changing the data structure made a whole ton of difference to the efficiency of the algorithm!

4. Identify redundant work ​

Here are a few examples of code which is doing redundant work. Although making these mistakes might not change the overall time complexity of your code, you are also evaluated on coding abilities, so it is important to write as efficient code as possible.

Don't check conditions unnecessarily ​

These are Python examples where the second check is redundant.

  • if not arr and len(arr) == 0 - the first check already ensures that the array is empty so there is no need for the second check.
  • x < 5 and x < 10 - the second check is a subcondition of the first check.

Mind the order of checks ​

  • if slow() or fast() - There are two operations in this check, of varying durations. As long as one of the operations evaluates to true , the condition will evaluate to true . Most computers execute operations in order from left to right, hence it is more efficient to put the fast() on the left.
  • if likely() and unlikely() - This example uses a similar argument as above. If we execute unlikely() first and it is false , we don't have to execute likely() .

Don't invoke methods unnecessarily ​

If you have to refer to a property multiple times in your function and that property has to be derived from a function call, cache the result as a variable if the value doesn't change throughout the lifetime of the function. The length of the input array is the most common example. Most of the time, the length of the input array doesn't change, declare a variable at the start called length = len(array) and use length in your function instead of calling len(array) every time you need it.

Early termination ​

Early termination. Stop after you already have the answer, return the answer immediately. Here's an example of leveraging early termination. Consider this basic question "Determine if an array of strings contain a string regardless of case sensitivity". The code for it:

Does this code work? Definitely. Is this code as efficient as it can be? Nope. We only need to know if the search term exists in the array of strings. We can stop iterating as soon as we know that there exists the value.

Most people already know this and already do this outside of an interview. However, in a stressful interview environment, people tend to forget the most obvious things. Terminate early from loops where you can.

Minimize work inside loops ​

Let's further improve on the example above to solve the question "Determine if an array of strings contain a string regardless of case sensitivity".

Note that you are calling search_term.lower() once per loop of the for loop! It's a waste because the search_term doesn't change throughout the lifecycle of the function.

Minimize work inside loops and don't redo work you have already done if it doesn't change.

Lazy evaluation is an evaluation strategy which delays the evaluation of an expression until its value is needed. Let's use the same example as above. We could technically improve it a little bit:

This is considered a micro-optimization and most of the time, strings won't be empty, but I'm using it to illustrate the example where you don't have to do certain computations if they aren't needed. This also applies to initialization of objects that you will need in your code (usually hash tables). If the input is empty, there's no need to initialize any variables!

How to optimize space complexity ​

Most of the time, time complexity is more important than space complexity. But when you have already reached the optimal time complexity, the interviewer might ask you to optimize the space your solution is using (if it is using extra space). Here are some techniques you can use to improve the space complexity of your code.

1. Changing data in-place/overwriting input data ​

If your solution contains code to create new data structures to do intermediate processing/caching, memory space is being allocated and can sometimes be seen as a negative. A trick to get around this is by overwriting values in the original input array so that you are not allocating any new space in your code. However, be careful not to destroy the input data in irreversible ways if you need to use it in subsequent parts of your code.

A possible way which works (but you should never use outside of coding interviews) is to mutate the original array and use it as a hash table to store intermediate data. Refer to the example below.

Note that in Software Engineering, mutating input data is generally frowned upon and makes your code harder to read and maintain, so changing data in-place is mostly something you should do only in coding interviews.

The Dutch National Flag problem could be easily solved with O(n) time and O(n) space by creating a new array and filling it up with the respective values in a sorted fashion. As an added challenge and space optimization, the interviewer will usually ask for an O(n) time and O(1) space solution which involves sorting the input array in-place.

An example of using the original array as a hash table is the First Missing Positive question. After the first for loop, all the values in the array are positive, and you can indicate presence of a number by negating the value at the index corresponding to the number. To indicate 4 is present, negate nums[4] .

2. Change a data structure ​

Data structures again!? Yes, data structures again! Data structures are so fundamental to coding interviews and mastery of it makes or breaks your interview performance. Are you using the best data structure possible for the problem?

You're given a list of strings and want to find how many of these strings start with a certain prefix. What's an efficient way to store the strings so that you can compute your answer quickly? A Trie is a tree-like data structure that is very efficient for storing strings and also allows you to quickly compute how many strings start with a prefix.

Next Steps ​

If you haven't already, I recommend you check out my free structured guide for coding interviews , which contains step by step guidance such as:

  • How to make an efficient plan for your coding interview preparation - including priority of topics and questions to study, based on the time you have left
  • Coding interview best practices cheatsheet - including how to behave during a coding interview to exhibit hire signals
  • Algorithms cheatsheets - including the must-remembers that you should internalize for every data structure

Table of Contents

  • 1. Visualize the problem by drawing it out
  • 2. Think about how you would solve the problem by hand
  • 3. Come up with more examples
  • 4. Break the question down into smaller independent parts
  • 5. Apply common data structures and algorithms at the problem
  • How to optimize time complexity
  • How to optimize space complexity

ForSoftwareEngineers header banner

How To Solve Coding Interview Questions (An Ultimate Guide)

Solving coding interview questions is the act of working through the types of problems that are asked during a software engineer technical interview. The problems that are asked during a technical interview (also known as a coding interview) are typically questions that require you to implement either a function or class structure in a popular programming language like Python, Java, C++, or JavaScript.

how to solve a coding interview problem

It’s important that you understand how to solve a coding interview problem optimally, and it is also important to understand what your interviewer requires you to do. Both aspects of solving a technical interview problem are important if your goal is to pass a coding interview.

There are methods to approaching solving coding interviews like the UMPIRE method (understand, match, plan, implement, review, and evaluate), but we suggest a methodology that enables you to emit more positive evaluation signals during an interview process.

To solve coding interview questions for the purpose of passing a coding interview, you will need to follow the instructions listed below (in the order they’re listed).

  • Understand the provided question
  • Determine the solution space
  • Analyze the solution space (in terms of big O)
  • Confirm a solution to code with your interview
  • Code your first solution
  • Test your code
  • Optimize your solution

coding interview time management

In the sections below, we will elaborate on what each of these steps requires you to do in order to solve technical interview problems with the intention of doing well in an interview. At the end of the article, we will discuss additional ways you can improve your chances of passing a coding interview. 

1. Understand The Provided Question

The first step to solving a coding interview problem is to understand the provided question you’re asked. If you don’t fully understand the question before you start thinking about and coding solutions then you’re automatically going to fail to solve the problem.

Understanding the provided question means making sure that you understand what the provided interview question expects you to do based on its inputs, outputs, and constraints. Detailed explanations of inputs, outputs, and constraints for solving coding interview problems are listed below.

  • Inputs : aspects of a coding problem to solve such as the method signature to a function you’re implementing and any helper functions (or classes) that your interviewer also provides you with to help you solve the problem.
  • Outputs : aspects of a coding interview problem in terms of what the output of your code should be.
  • Constraints : bounds for your inputs which depend on the type of your input. For instance, a constraint might be that your input will be a number between 1 and 100, so you don’t have to account for numbers outside that bound in your code.

You should ask clarifying questions that relate to the inputs, outputs, and constraints, to demonstrate that you understand the provided question to your interviewer. Clarifying questions are questions that you ask your interviewer for more detailed explanations of a specific aspect of an interviewer’s question. Additionally, you should run through examples of inputs and outputs, to further clarify your understanding of a problem.

What Are Good Clarifying Questions To Ask?

Good clarifying questions to ask include questions that are related to the inputs and outputs in terms of edge cases . Many interview candidates are able to successfully understand the inputs and outputs of basic cases, but often they forget to account for edge cases in inputs and what to return for edge cases within the code. 

Examples of clarifying questions are listed below.

  • Do I have to worry about null inputs or null outputs?
  • How should I represent empty return types (i.e., null, empty list, empty object)?
  • Do I have to make sure my solution covers <edge case>?

2. Determine The Solution Space

The second step to solving a coding interview during an interview is to ensure that you’re able to determine the solution space.

Determining the solution space when solving a technical interview problem means determining what the possible correct solutions are for a problem that you can implement. Typically, there’s an easy-to-identify brute force solution (a solution that is inefficient in terms of time and space, but easy to implement). However, interviewers typically don’t want you to implement a brute-force solution.

coding interview solution ideation

Your solution space should be determined before you start writing code. If you start writing code before finishing your solution space, your interviewer will likely consider that a negative signal toward your evaluation as a candidate because it expresses that you don’t think through solutions before implementing them.

How Do You Ideate Potential Solutions?

To ideate solutions when solving a coding interview problem, you should think about the best data structures and algorithms that can be used within the programming problem you’re asked . To do this, you should go through examples of solving the problem with your interviewer to identify patterns in the solution that map to specific data structures and algorithms.

Additional tips for ideating potential solutions when solving interview problems are listed below.

  • Visualize the problem : Illustrating what a solution to a problem looks like based on a problem statement is often easier than trying to think about the implementation in code. You can try to solve the problem by hand on a whiteboard (if interviewing in person) or in text within an IDE (if interviewing online) 
  • Break the problem down into smaller parts : Often, a problem can be split into smaller implementations that build up into a larger problem. Breaking a problem into sub-problems is a great way to ideate solutions that are more efficient. 
  • Ask for hints from the interviewer : While you should try to avoid directly asking your interviewer for hints, you can ask the interviewer for guidance if you’re stuck on finding more optimal solutions. If you are asking for hints, you should explain to your interviewer what you’ve already thought of and what you’re currently thinking of so they can understand your thought process. 

3. Analyze The Solution Space (Big O)

After you have your solution space, the next step is to analyze your solution space in terms of Big O time and space complexity. Time and space complexity is how software engineers compare the efficiency of programs at scale by understanding how efficient a program is in its worst case.

The table below shows the worst-case time and space complexities of a solution space to the LeetCode problem called Two-Sum.

Often, candidates either forget to mention the time and space complexities of the solutions or explain the time and space complexity after coding a solution. But remember, time and space complexity is an important aspect of solving the coding interview with the intention of passing the coding interview, so you should not forget to discuss this. 

Once you’re able to describe the solutions’ time and space complexities in Big O notation, make sure that you explain to your interviewer “why” each of the solutions should be the time and space complexities you’ve mentioned .

This can be considered difficult to do because you haven’t coded a solution yet, but you should at least communicate to your interviewer an education prediction of each solution’s time and space complexities which requires you to understand how each solution would be implemented without actually implementing it.

4. Confirm A Solution To Code With Your Interviewer

The next step is to confirm a solution to code with your interviewer. Confirming a solution to code with your interviewer means making sure that you’re both aligned with the solution and approach you’re going to use in solving the coding problem your interviewer provided you with.

This step is important because your interviewer may be able to guide you through certain aspects of a solution that you haven’t thought about yet that would come up while you’re coding. Additionally, it provides good communication signals to your interviewer which is good for your coding interview evaluation. 

To approach confirming a solution to code with your interview, try and make a recommendation based on your solution space analysis in terms of time and space complexity . Generally, software engineer coding interviewers will expect you to pick and implement the solution optimized for the best time complexity. However, it’s important to confirm this with your interviewer in case they are evaluating based on a different solution for the purpose of your current interview.

5. Code Your First Solution

The fifth step you must to do solve a coding interview question during an interview is to code your first solution. Coding your first solution means writing working code based on the solution you agreed upon coding with your interviewer. 

You’ll want to make sure that you’re communicating with your interviewer throughout the duration that you’re coding your first solution. In fact, this is a part of how you should communicate with your interviewer during a coding interview because you’re trying to maximize the amount of positive feedback that your interviewer can write down about you within their evaluations.

Sometimes, it’s difficult to map a solution to working code, so it might be beneficial to write down brief notes about the solution’s implementation as pseudo code before you start coding. However, you should not spend more than 2 minutes writing pseudo code because you don’t have that much time during the duration of a coding interview (about 20 to 30 minutes of coding time) to code a complete solution.

6. Test Your Code

After you code your first solution, the next step is to test that the code you’ve written for your solved problem is correct. Testing your code means applying inputs into your code and validating that your code outputs are correct. The validation process that your code works as intended is a manual process where you’ll be expected to take a test case and go through your code as if you’re a computer . However, Some companies allow you to run automated test cases in an IDE. 

When you’re going through your code to make sure that it works, make sure that you’re tracking the state of your program exactly as it’s written as code. Often, candidates will make the mistake of talking about their code as they intend it to work rather than how it actually works.

To do this, you can track all of the variables and how each variable is changing throughout your program’s execution. Additionally, you can pay close attention to any complex boolean evaluations that are done by your program, making sure to never assume you know the value of an evaluation and computing it every time.

If you find a bug in your code, take some time to consider what needs to be fixed. Identify the broken state of your program and communicate with your interviewer the entire time. You’re not expected to write perfect code when you code your first solution. However, if there are mistakes in your code, it’s a good signal to your interviewer if you’re able to identify all the mistakes and fix them all yourself.

7. Optimize Your Solution

The last step to solving a coding interview problem within a software engineer technical interview is to optimize your solution. Optimizing your solution means looking at your code and making it run as fast as possible using as little memory as possible.

At the optimization stage of solving a technical interview problem, you’re looking for both time and space complexity optimizations and microcode optimizations that are less impactful (like variable position changes and reducing the number of required function calls).

In practice, you’ll likely only need to describe what you would do to optimize your solution to your interviewer at this point because you’ll be near the end of an interview. However, you’ll want to confirm what you should do with your interviewer. 

How Do You Optimize A Solution?

To optimize a solution in a coding interview, you’ll want to follow a framework for identifying what can be simplified or moved around for efficiency. A popular framework for optimizing solutions is by following the BUD framework which stands for reducing bottlenecks, unnecessary work, and duplicated work .

Why Is Solving A Coding Interview Problem Not Enough To Crack The Coding Interview?

Solving a coding interview problem is not enough to crack the coding interview because being able to solve a coding interview problem is only one of the criteria in the 3 total criteria for coding interviews. The other criteria that you’re evaluated in a coding interview are communication skills and analytical abilities. 

In order to increase your odds of passing a coding interview , you will want to make sure that you make use of all the resources that you can to improve your problem-solving skills, communication skills, and analytical abilities. These resources include books, courses, and mock interview platforms.

What Resources Can Help You Pass Technical Coding Interview?

Resources that you can use to pass a coding interview are listed below.

  • Coding Interview Books : Cracking the Coding Interview is an example of a book that explains all of the components of a coding interview that you should know about in order to solve interview problems and pass interviews. 
  • Coding Interview Courses : AlgoExpert is an example of a coding interview course that provides you with videos that show you how to solve coding interview problems. 
  • Coding Interview Mock Interview Platforms : Pramp is an example of a free mock coding interview platform that you can use to practice solving coding interview problems.

Joseph Onifade

Joe Onifade is an ex-Google software engineer, and over the past 3 years, he's worked as a full-stack software engineer but becoming a backend-focused engineer. His programming interests span developing scalability systems and web3.

Similar Posts

The Ultimate Guide to Solving BFS and DFS LeetCode Problems

The Ultimate Guide to Solving BFS and DFS LeetCode Problems

Whenever I get asked about depth-first search (DFS) or breadth-first search (BFS) problems within an interview nowadays, I grin because of how generally easy these types of problems are to solve after I created and memorized my templates for DFS/BFS problems. BFS/DFS problems are easy to do once you understand the basic mechanisms and “code…

LeetCode vs. Codewars: Which Is Better For Coding Interviews?

LeetCode vs. Codewars: Which Is Better For Coding Interviews?

LeetCode is a website that is often compared to another website called Codewars because of its similar offerings in terms of providing a coding interview preparation platform for software engineering candidates. For instance, both of these platforms allow you to solve coding interview questions on their platforms, submit questions to evaluate for correctness, and learn…

LeetCode vs. AlgoExpert: Which Is Better For Coding Interviews?

LeetCode vs. AlgoExpert: Which Is Better For Coding Interviews?

Any time people think of coding interview preparation, they’ll often think of LeetCode. LeetCode is the most popular online platform that people use to practice coding interview problems for free. A popular competitor to LeetCode for interview preparation is a website called AlgoExpert. Is AlgoExpert, the $99 per year technical interview preparation product, better than…

7 Best LeetCode Alternatives For Interview Preparation

7 Best LeetCode Alternatives For Interview Preparation

A LeetCode alternative for interview preparation refers to an online platform or resource designed to help software engineering candidates prepare for technical interviews, particularly focusing on coding challenges and algorithmic problems. These alternatives often provide a curated collection of coding questions that cover essential topics like data structures, algorithms, and problem-solving techniques commonly encountered in…

9 Essential Data Structures For Coding Interviews

9 Essential Data Structures For Coding Interviews

A data structure is a specialized framework that dictates how data is stored, manipulated, and retrieved. Various data structures are designed to represent distinct types of data within a program. Each structure offers unique use cases, advantages, and disadvantages toward time and space complexity. A coding interview tests your knowledge of commonly used and known…

6 Best Courses For Coding Interviews (2023)

6 Best Courses For Coding Interviews (2023)

Courses for coding interviews are a great way to learn about what you need to do to pass coding interviews in a structured way. The courses cover content such as the fundamentals of data structures, algorithms, and solving coding interview problems. The current 6 best online courses (also known as coding interview bootcamps) for coding…

  • Crimson Careers
  • For Employers
  • Harvard College
  • Harvard Kenneth C. Griffin Graduate School of Arts & Sciences
  • Harvard Extension School
  • Premed / Pre-Health
  • Families & Supporters
  • Faculty & Staff
  • Prospective Students
  • First Generation / Low Income
  • International Students
  • Students of Color
  • Students with Disabilities
  • Undocumented Students
  • Explore Interests & Make Career Decisions
  • Create a Resume/CV or Cover Letter
  • Expand Your Network
  • Engage with Employers
  • Search for a Job
  • Find an Internship
  • January Experiences (College)
  • Find & Apply for Summer Opportunities Funding
  • Prepare for an Interview
  • Negotiate an Offer
  • Apply to Graduate or Professional School
  • Access Resources
  • AI for Professional Development and Exploration
  • Arts & Entertainment
  • Business & Entrepreneurship
  • Climate, Sustainability, Environment, Energy
  • Government, Int’l Relations, Education, Law, Nonprofits
  • Life Sciences & Health
  • Technology & Engineering
  • Still Exploring
  • Talk to an Advisor

45 Common Coding Interview Questions

  • Share This: Share 45 Common Coding Interview Questions on Facebook Share 45 Common Coding Interview Questions on LinkedIn Share 45 Common Coding Interview Questions on X

45 Common Coding Interview Questions was originally published on Forage .

student coding on laptop

A coding interview can be nerve-racking, but it’s an essential part of the technical interview process to demonstrate your programming skills and knowledge of coding concepts. While the exact questions a technical recruiter might ask vary depending on what kind of role you’re applying for, there are some common coding interview questions you can prepare for to ace the interview. We’ll cover:

Programming Interview Questions

Conceptual coding interview questions, general coding interview questions.

A coding interview typically starts with an assessment of your computer programming skills. This assessment might be a whiteboard challenge or coding test.

What Is a Whiteboard Challenge?

A whiteboard challenge is when you’re given a coding challenge during a live interview . You solve the problem in front of the interviewer and explain your process as you work on the challenge.

You can use the UMPIRE method to approach these problems:

U: Understand the problem M: Match the problem with the interviewer P: Plan your approach and solution I: Implement your solution R: Review your solution E: Evaluate your solution

To prepare for a whiteboard challenge, “practice talking through your problem-solving process ,” says Archie Payne, president of CalTek Staffing, an IT and technical staffing firm. “Interviewers don’t just want to see that candidates can complete the test task, they also want to get insights into how candidates approach the process. A good way to prepare is to pretend you’re teaching a programming class, and practice how you’d explain and demonstrate key concepts to someone who doesn’t know them.”

It’s less about solving everything right the first time (or even at all) and more about learning how you approach problems and solve challenges. 

And what happens if you don’t know the answer? Don’t panic.

“Be honest that this is a gap in your knowledge,” Payne says. “Take a moment to think critically about the problem and the ways you’d likely approach it, then explain that process to the interviewer. Hiring managers don’t necessarily expect entry-level candidates to have all the answers, but they do want to hire someone who’s self aware about what they do and don’t know, and willing to learn and try new things.”

What Is an Independent Coding Test?

An indepdent coding test focuses on your ability to code and solve problems within a given time frame. You may have an independent coding test after your whiteboard test or before as part of a screening. 

The company will give you a link to a common code editor, and you can choose what programming language you want to write in. Before you start the test, you’ll know how long you have to complete it and whether you’ll be able to leave the platform during the test. Make sure you do the test in a quiet environment where you won’t have distractions.

To prepare for this part of the interview, “​​simulate interview conditions,” Mohit Maheshwari, co-founder at NMG Technologies, a full-service IT company, says. “Practice coding on a whiteboard or a blank sheet of paper, as this is how you will be doing it during the interview. Get used to writing code without the aid of an IDE [integrated development environment] or compiler.” 

jpmorgan logo

JPMorgan Chase Software Engineering

Practice basic programming skills with a Python project.

Avg. Time: 5 hours

Skills you’ll build: Python, Git, React, Typescript, technical communication

Common Programming Interview Questions

What questions will you get in a whiteboard challenge or independent coding test? Here are some examples:

  • How do you reverse a string?
  • How do you determine if a string is a palindrome?
  • How do you calculate the number of numerical digits in a string?
  • How do you find the count for the occurrence of a particular character in a string?
  • How do you find the non-matching characters in a string?
  • How do you find out if the two given strings are anagrams?
  • How do you calculate the number of vowels and consonants in a string?
  • How do you total all of the matching integer elements in an array?
  • How do you reverse an array?
  • How do you find the maximum element in an array?
  • How do you sort an array of integers in ascending order?
  • How do you print a Fibonacci sequence using recursion?
  • How do you calculate the sum of two integers?
  • How do you find the average of numbers in a list?
  • How do you check if an integer is even or odd?
  • How do you find the middle element of a linked list?
  • How do you remove a loop in a linked list?
  • How do you merge two sorted linked lists?
  • How do you implement binary search to find an element in a sorted array?
  • How do you print a binary tree in vertical order?

coding problem solving interview questions

Forage Find

LeetCode is a great resource for practicing these types of questions. You can create a free account and practice hundreds of coding questions you might get in an interview.

The recruiter or hiring manager will also ask conceptual coding interview questions to learn whether you’re familiar with the concepts you’ll be working with. 

“Expect questions on basic data structures such as arrays, linked lists, trees, and graphs, as well as common algorithms like sorting and searching,” Maheshwari says.

To prepare for these questions, refamiliarize yourself with these concepts. Then, you can practice by explaining them clearly to someone who doesn’t have technical knowledge.

Examples of these questions include:

  • What is a data structure?
  • What is an array?
  • What is a linked list?
  • What is the difference between an array and a linked list?
  • What is LIFO? 
  • What is FIFO?
  • What is a stack?
  • What are binary trees?
  • What are binary search trees?
  • What is object-oriented programming?
  • What is the purpose of a loop in programming?
  • What is a conditional statement?
  • What is debugging?
  • What is recursion?
  • What are the differences between linear and non-linear data structures?

>>MORE: Learn explanations of common software engineering technical concepts with entry-level software engineering interview questions (and answers) .

Outside of programming questions and questions about technical concepts, you might answer questions about your general experience, like how you learned to code, behavioral interview questions , and how you keep your skills fresh. 

Examples of general common coding interview questions include:

  • What programming languages do you have experience working with?
  • Describe a time you faced a challenge in a project you were working on and how you overcame it.
  • Walk me through a project you’re currently or have recently worked on.
  • Give an example of a project you worked on where you had to learn a new programming language or technology. How did you go about learning it?
  • How do you ensure your code is readable by other developers?
  • What are your interests outside of programming?
  • How do you keep your skills sharp and up to date?
  • How do you collaborate on projects with non-technical team members?
  • Tell me about a time when you had to explain a complex technical concept to a non-technical team member.
  • How do you get started on a new coding project?

“Be prepared to explain your expertise in the languages you know and what types of projects you’ve completed using them,” Payne says. “​​The ability to troubleshoot and correct issues as you go is a key skill for programmers at all career levels. The best answer will focus on the steps you take to diagnose and fix issues, rather than the intricate details of the specific problem you’re describing.”

Common Coding Interview Questions: The Bottom Line

Programming interview questions generally come in three different forms: practical coding tests, questions about technical concepts, and general questions about your experience. To ace a coding interview, prepare carefully for each section: practice problems, review concepts, and use the STAR method to shape answers about your experience.

Are you getting ready for a coding interview? Practice sample coding problems with matrices and arrays and learn what hiring managers look for in technical interviews with Girls Who Code’s Technical Interview Prep .

Image credit: Canva

The post 45 Common Coding Interview Questions appeared first on Forage .

JavaScript Coding Interview Practice – Sample Interview Questions and Solutions

Damla Erkiner

David Goggins is an ultramarathon runner, a public speaker, a retired navy SEAL, and the author of the book ' Can't Hurt Me: Master Your Mind and Defy the Odds '. He's one of my role models because of his physical strength and mental resilience.

You might say: "Wait a second! We get it. This person is obviously the epitome of success. But he has non-technical skills. So why is he relevant to JavaScript coding interviews?"

Well, if you're ready, let's explore this together.

Rocky Balboa As a Mentor

In response to a question, David says, 'The Rocky Movie changed my life." In that pep talk , he refers to this scene (min 1.30-1.42) where the fictional character, Rocky - despite being beaten up badly by his opponent in the final boxing round - refuses to give up no matter what.

David describes that particular moment as the time when Rocky - initially depicted as an underdog by the screenwriter - overcomes all the odds and strikes awe in his rival.

image-280

Let's admit it. Being a good programmer is not that easy. And especially if you are at the beginning of your career, technical job interviews can be seriously daunting. In short, it might be nice to reach David's (and Rocky's) mindset.

With that kind of drive and confidence, you're much less likely to consider giving up regardless of the types of challenges you face in your wonderful yet difficult journey of getting a developer job.

Why Coding Interviews Are Difficult

During coding interviews, you are expected to fix coding problems with some theoretical knowledge. But the caveat is you must do that in real time, which sometimes scares new developers off.

There are several types of coding interviews. But the most challenging one is probably a whiteboard interview. In these types of interviews, you have to code in front of a future employer / a senior software developer.

image-319

These interviews can be extra stressful because you are typically not allowed to have a computer to google any unknown concepts or to get some code snippets from the internet. You are only given a marker to solve the question on a whiteboard as the name suggests.

Do Interviews Reflect What You'll Do in Your Job?

Not necessarily. So why are they holding these scary coding interviews? Well, the reason is to test your problem solving skills in general. At times, finding the correct answer may not even be that important.

What matters is how you reach that conclusion / solution and which algorithms you prefer to use along the way. In other words, your ability to function well under stress is being tested by tech companies.

image-329

Let's face it. You'll come across lots of stressful situations in your future job, and how you deal with certain issues is especially crucial. Therefore, your future employer naturally wants to witness firsthand whether you are the right fit for the job.

What is the Purpose of This Tutorial?

In this post, I'll walk you through some popular JavaScript interview concepts through examples. I'll also do my best to show you what recruiters / interviewers might actually be looking for in a candidate while they code in front of them.

To simply put, we'll examine some models and try to solve the related puzzles together.

By the end of this tutorial, you'll hopefully have an idea about a number of important array methods. But most importantly, you'll unlock how to approach some coding challenges in the best way possible.

What Exactly is the Memory Palace Method?

Before we start, just be aware that in the sample data down below, I've used some late celebrities' names intentionally so that all those details can be catchy in the long run.

An ancient technique called the Memory Palace clearly says that the weirder the details, the easier it is to remember them – and a made-up story / creating context is even more effective.

If you try to visualise the related situation vividly and associate the given programming concepts with some bizarre details in your mind, you might feel less stressed and confused when you see a similar problem next time. This is because it might be easier for you to create specific links and as such remember things easily. This is how our brains work.

Well, even the fictional figure ' Sherlock Holmes ', the smartest guy on the planet, benefits from this method when solving complicated crimes – so why shouldn't we?

image-321

How to Approach Coding Problems

In our imaginary interview, you'll see that four extraordinary musicians from the past are listed as passengers on a flight. We have their food choices and the number of connecting flights they need to take after their incredible performances on stage in different parts of the world.

Let's say just for the sake of argument our phenomenal figures (Freddie Mercury, Amy Winehouse, Kurt Cobain, and Michael Jackson) are about to fly from different destinations to Los Angeles just to be able to dine out together at a swanky restaurant, as they enjoy each other's company so much.

After all, this is our own private memory palace, so we can absolutely do whatever we want to do in our minds. Remember unusual details will stick better. That's why I'm trying to add more to spice things up.

This method explicitly suggests describing every single detail with some vivid adjectives so that you can associate them with the things you plan to learn in the long run.

Scientists say short term memory and long term memory function very differently. To put it simply, we need a way to put all those core concepts (not necessarily the syntax) about programming in our long term memory. That's why it can be nice to benefit from the memory palace method in our journey.

image-326

Plus, I feel like you get to picture this unusual scenario with a smile on your face. Well, wouldn't it be great if these awesome souls could have seen that they are now helping us / the programming community as the guests of a freeCodeCamp article?

Sample Interview Questions

Let's get back to the real life now though. Remember you're still in the interview and as you see below, three questions in a row are waiting for you.

To solve the puzzles, you're expected to use the data inside the following array of objects in practical ways.

You'll certainly need to come up with the right algorithms and try to find the most effective solution that can satisfy the interviewer.

The above questions are in fact not that hard. But, how we'll handle them is a great opportunity to compare alternative solutions for a single problem. At the end of the day, quality is what counts for recruiters / interviewers.

Interview Question 1: How to Get Passengers' Names

Let's get the passengers' names as requested. The first solution is through a 'for loop' method. So we first need to use an empty array to push the passengers' names right inside it at the end of the loop.

Below, [i] represents the current passenger and we simply loop through the 'passengers' array to access the names of the passengers. Then, we need to lock them up in our empty array / passengerNames.

image-331

Alright, we solved the puzzle, but is it enough? Or might the interviewers expect you to come up with a better solution?

Alternative Solution #1:

We can reach the desired result by using the ' forEach ' function as well. This solution is even a bit better than the previous one because there is no index expression in this one.

image-332

To benefit from 'forEach', we need a callback function . With this arrangement, we are able to reach every passenger in the list. However, just like in the previous solution, we first need an empty array to push the items / passengers' names.

Even though the result is the same, this piece of code is shorter. Writing neater codes is what is – in fact – expected from you.

In other words, not only the solution matters, but also how you reach it is being evaluated by the recruiters. For this reason, it is a good idea to plan your action rather than writing the first idea in your mind on the whiteboard.

Alternative Solution 2:

Here comes the best solution. We can also utilise the ' map ' function to tackle the same problem. Let's see how.

image-333

The map function also loops through the array and returns a new array for every item in the list. With this set-up, we simply return a single element, not an object.

The result will again be the same in the console, but your code will even be better than the first and second one because this time, we don't need to create an empty array before the actual task.

Here is the food for thought on this topic. Those who say 'less is more' have a point when it comes to writing codes.

Interview Question 2: How to Get Vegetarian/Vegan Singers

Let's now take a look at the next challenge. The new task asks us to obtain only the vegetarian / vegan singers from the passengers' list by also keeping the first argument in the main question section.

How to Solve With a 'For Loop'

Again, we can use the same old 'for loop' for this one as well. All we need to do is to check whether there are any vegetarian / vegan singers in our passenger list through an 'if' statement inside our existing function.

image-334

We do that with the isVegetarianOrVegan property in our object. Basically, what we say is this: if the relevant statement is true (if there are any vegan / vegetarian passengers in the list), just push those items into our new array. The result will give us three singers' names as those are listed as  'vegetarian or vegan' in the data part.

How to Solve with 'forEach'

As a matter of fact, the 'forEach' function handles the problem similarly. But once again, it has too many lines of codes as you see below, so it isn't the ideal version.

image-335

How to Solve with 'Filter' & 'Map'

To come up with the best option, this time, we will use two different methods. The ' filter ' and the 'map' functions will – in a way – collaborate to create better logic when solving the given problem. Let's examine the following code snippet closely now.

image-336

With the filter method, we only get the vegetarian / vegan passengers from our array in the first place. If it finds some non-vegetarian / vegan passengers (like our beloved 'Freddie'), it will get rid of them automatically.

Briefly, the first part of the equation, the 'filter' method will simply work through 'yes' or 'no' model.

Then, the 'map' function will come in, eventually giving us a brand new array showing the vegetarian / vegan passengers only.

This final solution will prove your future employer that you genuinely know what you're doing and you are really taking the right steps to be a hotshot developer.

Interview Question #3: How to Sort Passengers by Connecting Flights

The last section asks us to sort the list of our super cool passengers by the number of the connecting flights they'll take to eventually reach LA. Let's see who has more and as such, will be pretty exhausted.

Spoiler alert! Amy with four connecting flights in total might be a bit sleepy in the get-together at that fancy restaurant. But there is no doubt that she will somehow rock where ever she goes.

image-322

Anyway, what we need for this task is to know how the ' sort ' function operates.

Primarily, it compares items one by one and returns something as a result. In our case, it will be the number of connected flights. But how does it make that comparison? What is the logic behind that?

image-343

The above lines of code are pretty clear in general. Thanks to the 'sort' function, we list those months in alphabetical order.

Well, here comes the big question. How does the code / system know that 'a' is the first letter of the alphabet and as such, the list starts with the 'd' letter (December)?

The reason is that the 'sort function' lists things in ascending order by default. But can't we change this setting? Perhaps, we need to list items in descending order. Of course, we can.

Let's see how. To achieve what we want, we may utilise 'a' and 'b' letters as parameters leading to different directions.

image-338

Simultaneously, we can benefit from the assistance of three numbers: -1,+1, 0 as seen above. When sorting items in descending or ascending order or finding the equal values, they can be quite handy.

Tricky Bit of the 'Sort' Function

In the following example, the list is sorted in ascending order. Why is it like that? Here is the reason. When we return those 'a' and 'b' parameters, we use this order:  'a - b' . That gives us ascending values by default.

image-339

However, if we swap them and say 'b - a', the list will be seen in descending order this time. That's the tricky bit when it comes to the 'sort' function.

In the above example, the first version (regular function) and the second one (arrow function) are in essence the same, but just be aware that arrow functions came with ES6 .

Although arrow functions help developers to write less code, you cannot use them everywhere. (Read this to find out when to use them.)

Testing Our New Knowledge

Shall we now analyse the situation of our passengers through our new perspective? We know that the last task asks us to sort the number of flights in descending order. But the following set-up does the opposite.

It can only give us the list in ascending order. Why? It's simply because of the pre-defined order (passenger1.connectedFlights - passenger2.connectedFlights) as in the case of a - b example.

Once we swap the order (passenger2.connectedFlights - passenger1.connectedFlights) as you see in the following code snippet, our problem will be solved and the list will come in descending order.

image-342

Can We Also Use 'for loop' or 'forEach'?

Well, yes and no. Both would be low-level solutions for this question.

We should keep in mind that the sort function mutates an array. This is a kind of side effect which changes the original array and that might be a problem if we use 'for loop' or 'forEach' as a solution.

There are of course ways to avoid mutation in the sort function, but in our example, it will lead to more lines of codes, which is not practical at all.

Wrapping Up

We've started the article with David Goggins, the symbol of resilience and grit, so let's end it with his inspiring presence and ideas.

If you happen to read this modern day hero's book or listen to one of those famous podcast episodes (For example, this one ) where he was a guest speaker, you'll immediately understand that he wasn't born that way. Rather, his secret lies in the fact that he never gives up, against all odds.

Coding interviews are tough, but if you keep going after your goals by visualising the scene of success in your mind over and over again, it will -  sooner or later - be yours.

image-328

Many thanks for reading this post. If you've liked this article, one of the best ways to support me is to share it. Should you have any questions or comments, you can always contact me via LinkedIn . I'll be more than happy to help you out with your queries.

Happy coding!

“Knowledge is power.” – Francis Bacon

Software Developer || UI Designer || Technical Writer

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

Top 26 coding questions to crack the Microsoft interview

Microsoft Interview Coding Question

20. Rat in a Maze

Problem Statement : Consider a rat placed in a square n*n matrix at position (0, 0) . Find all possible paths the rat can take to reach its destination (N-1, N-1) from its starting position.

The rat can move vertically and horizontally. Cells with a value of 1 can be traversed, while cells with a value of 0 cannot. The rat cannot visit a cell more than once.

21. Solve the Sudoku

Problem Statement : Given a square matrix grid of 9*9 and configured to represent an incomplete Sudoku puzzle, find a solution that returns a true or false value depending on whether or not the Sudoku can be completed. If a solution is possible, your solution must also return the completed grid.

22. Clone a directed graph

Problem Statement : Given the root node of a directed graph, clone this graph by creating its deep copy so that the cloned graph has the same vertices and edges as the original graph.

23. Conduct a Breadth-First Traversal of a given graph

Problem Statement : Starting from the source node, traverse a given graph breadthwise to find the distance between the source node and node n .

24. Check if there’s a path from a source to its destination

Problem Statement : Given a graph n*n with each cell containing a value of 0 , 1 , 2 , or 3 , return a true or false value depending on whether or not one can find a path from the source node to the destination node. Each graph will have one source node and one destination node. The graph can be traversed horizontally and vertically.

The cell containing a value of 0 is the source node. A value of 1 represents a wall; this node is impassable. A value of 2 represents a blank cell that can be traversed. A value of 3 represents the destination node.

Sort and Search

25. find the closest meeting point.

Problem Statement : Given n people on a square grid, find the point that requires the least total distance covered by all people to meet at that point.

26. Search for the given key in a two-dimensional matrix

Problem Statement : We are given a two-dimensional array where all elements in any individual row or column are sorted. In such a matrix, we have to search or find the position of a given key.

Be prepared to go over

  • Data structures : Arrays , strings, queues, lists, linked lists , stacks , trees , heaps , hash tables, hash maps, hash sets , graphs , and more.
  • Algorithms : Breadth-first search, depth-first search, binary search, quicksort , mergesort , dynamic programming , divide-and-conquer, and more.
If you have over 3 years of experience developing software, it is highly likely that you will be asked system design questions, which can be more open-ended. To get an idea of what to expect from a system design interview, check out the Top 10 system design interview questions for software engineers .

The timeline for the entire process (from submitting your resume to receiving a job offer) takes approximately 1-2 months You are encouraged to use whatever mainstream programming language (e.g., C/C++ or Java) that you are most comfortable with to solve the technical questions.

  • Prescreening : A recruiter contacts you via email to schedule a 45-minute phone call. They will spend 15 minutes going over your resume and asking behavioral questions. You have the remaining 30 minutes to solve a coding question related to algorithms and data structures in a shared editor.
  • Phone interview : The recruiter contacts you within two weeks to schedule a phone interview with a senior developer or engineering manager. Information about potential topics that may be covered during this phone interview will be provided in advance.
  • On-site or virtual interview : After passing the phone interview, you will be invited to participate in 4-5 rounds of interviews either in-person at the Microsoft campus or virtually. Each round is an hour long and will be conducted by two members of the team you’re looking to join. These rounds will have both behavioral and technical questions.
  • Lunch interview : Halfway through the rounds, you will be taken out to lunch for a more casual conversation. This will take place on the Microsoft campus, or off-campus at a restaurant.
  • Final interview of the day : The last round will be conducted by an AS-AP (As-Appropriate) who will have the final say in hiring you.
  • HR interview : The hiring manager will go over any remaining behavioral or technical questions not covered in the previous rounds of interviews, make an offer, and discuss compensation.

Microsoft develops a holistic view of you as a candidate using competency-based questioning in addition to your resume. They want candidates with strong technical skills that align well with the company values.

Step 1: Update your resume

The first thing you want to do is to make sure your resume and LinkedIn profile are up to date. Be very specific, and use deliverables and metrics whenever possible.

Next, you’ll want to look at your resume in the context of the Microsoft Core Competencies. Consider how specific projects or experiences can be tied into different Core Competencies, and update them to reflect ways in which you have prioritized these values in your work.

Step 2: The 12-week interview prep roadmap

To fully prepare yourself for the coding interview, we strongly suggest that you take three months to go over technical concepts and practice solving interview questions. Using an interview prep roadmap is a great way to keep track of your progress, and break down what you need to learn.

You can use our Definitive Interview Prep Roadmap to make sure you’re hitting all of the important topics that might be covered during coding interviews.

  • Week 0 - What programming language should you use?
  • Week 1 - Brush up on your chosen programming language.
  • Weeks 2 & 3 - Data structures and algorithms.
  • Weeks 4 & 5 - Practice simple data structures and algorithmic challenges
  • Weeks 6, 7 & 8 - Dive into more complex coding interview problems
  • Weeks 9 & 10 - System design interviews
  • Week 11 - OS and concurrency concepts
  • Week 12 - Object-oriented design interviews

Step 3: Prepare for the behavioral interview

Behavioral interview questions typically fall into one of three categories:

  • Past experiences
  • Hypothetical situations
  • Values-based questions

Behavioral interviews help interviewers decide if you’re someone they would want to work with. Reflect on how you react to positive situations or conflicts in a professional setting, and be honest about your past experiences. Essentially, be your authentic self.

Don’t be afraid to bring your unique perspective to the table. Go beyond just answering questions. Really listen and respond to your interviewers. Show them that you’re engaged and tuned into the conversation you’re having with them.

The most important thing to keep in mind for any behavioral interview is that your interviewers want to hire you. If you’re enthusiastic about the technology you’ll be working with, don’t be afraid to show it!

If you want to brush up on behavioral interview questions, then check out How to prepare for the Behavioral Interview to learn more about what interviewers are looking for, and how you can develop the kind of structured responses that impress them.

You can also read up about the key attributes that define the culture at Microsoft.

Microsoft Software Engineer Interview

According to research, less than 2% of candidates pass through all rounds of the Microsoft software engineer interview process. Although Microsoft was one of the first companies to exclude tough brain teasers from their coding interviews, passing through is still pretty challenging. You need expert guidance and the right practice questions to upscale your interview skills.

Microsoft software engineer interviews usually consist of 5-6 rounds on the same day. Microsoft, being one of the premier technology giants, wants to ensure that they hire the best and brightest minds in the industry. That’s why a major part of the interview process consists of technical questions to analyze your problem-solving abilities and critical thinking. We have mentioned the most frequently asked questions during a Microsoft software engineer interview. For a detailed coding interview prep, you can try Educative-99 and the exclusive interview prep courses that Educative offers.

Educative-99 in Python

Educative-99 in Go

Educative-99 in JavaScript

Educative-99 in Java

Educative-99 in C++

Microsoft’s multi-faceted approach ensures that candidates can tackle intricate technical challenges while also demonstrating adaptability, teamwork, and alignment with Microsoft’s values and culture. This dual emphasis paves the way for engineers who are adept both at coding and co-creating in a dynamic environment.

Now that you’re more familiar with the Microsoft interview process, it’s time to make a plan and put it into action! The best candidates come fully prepared, so it’s important to exercise due diligence. We’ve put together an extensive course that will help you quickly identify any gaps in your knowledge, test your skills, and practice using a live, in-browser coding environment.

You can visit our Decode the Coding Interview library. The Decode series exposes you to some of the most frequently asked questions at tech companies and helps solidify your knowledge by contextualizing these problems in real-world applications.

Happy learning!

Related courses

  • Grokking Coding Interview Patterns in Java
  • Grokking Coding Interview patterns in C++
  • Grokking Coding Interview patterns in Python

Related articles

  • Top 5 hardest coding questions from FAANG recent interviews
  • Top 7 salary negotiation tips for software developers
  • How to ace a coding interview even if you can’t solve the problem
  • Top 10 system design interview questions for software engineers

Educative Unlimited

If you like our content, consider signing up for Educative Unlimited today!

Haven’t found what you were looking for? Contact Us

How do I prepare for a Microsoft interview?

The preparation depends on the position for which you’re applying. Educative-99 is a great resource to practice your coding skills. Curated by industry experts, Educative-99 includes the most commonly asked technical questions to help you prepare for your Microsoft interview.

Learn in-demand tech skills in half the time

Mock Interview

Skill Paths

Assessments

Learn to Code

Tech Interview Prep

Generative AI

Data Science

Machine Learning

GitHub Students Scholarship

Early Access Courses

For Individuals

Try for Free

Gift a Subscription

Become an Author

Become an Affiliate

Earn Referral Credits

Cheatsheets

Frequently Asked Questions

Privacy Policy

Cookie Policy

Terms of Service

Business Terms of Service

Data Processing Agreement

Copyright © 2024 Educative, Inc. All rights reserved.

Top 72 Swift Interview Questions

25+ JavaScript Coding Interview Questions (SOLVED with CODE)

Having a JavaScript Coding Interview Session on this week? Fear not, we got your covered! Check that ultimate list of 25 advanced and tricky JavaScript Coding Interview Questions and Challenges to crack on your next senior web developer interview and got your next six-figure job offer in no time!

Q1 :   Explain what a callback function is and provide a simple example

A callback function is a function that is passed to another function as an argument and is executed after some operation has been completed. Below is an example of a simple callback function that logs to the console after some operations have been completed.

Q2 :   Given a string, reverse each word in the sentence

For example Welcome to this Javascript Guide! should be become emocleW ot siht tpircsavaJ !ediuG

Q3 :   How to check if an object is an array or not? Provide some code.

The best way to find whether an object is instance of a particular class or not using toString method from Object.prototype

One of the best use cases of type checking of an object is when we do method overloading in JavaScript. For understanding this let say we have a method called greet which take one single string and also a list of string, so making our greet method workable in both situation we need to know what kind of parameter is being passed, is it single value or list of value?

However, in above implementation it might not necessary to check type for array, we can check for single value string and put array logic code in else block, let see below code for the same.

Now it's fine we can go with above two implementations, but when we have a situation like a parameter can be single value , array , and object type then we will be in trouble.

Coming back to checking type of object, As we mentioned that we can use Object.prototype.toString

If you are using jQuery then you can also used jQuery isArray method:

FYI jQuery uses Object.prototype.toString.call internally to check whether an object is an array or not.

In modern browser, you can also use:

Array.isArray is supported by Chrome 5, Firefox 4.0, IE 9, Opera 10.5 and Safari 5

Q4 :   How to empty an array in JavaScript?

How could we empty the array above?

Above code will set the variable arrayList to a new empty array. This is recommended if you don't have references to the original array arrayList anywhere else because It will actually create a new empty array. You should be careful with this way of empty the array, because if you have referenced this array from another variable, then the original reference array will remain unchanged, Only use this way if you have only referenced the array by its original variable arrayList .

For Instance:

Above code will clear the existing array by setting its length to 0. This way of empty the array also update all the reference variable which pointing to the original array. This way of empty the array is useful when you want to update all the another reference variable which pointing to arrayList .

Above implementation will also work perfectly. This way of empty the array will also update all the references of the original array.

Above implementation can also empty the array. But not recommended to use often.

Q5 :   How would you check if a number is an integer?

A very simply way to check if a number is a decimal or integer is to see if there is a remainder left when you divide by 1.

Q6 :   Implement enqueue and dequeue using only two stacks

Enqueue means to add an element, dequeue to remove an element.

Q7 :   Make this work

Q8 :   write a "mul" function which will properly when invoked as below syntax.

Here mul function accept the first argument and return anonymous function which take the second parameter and return anonymous function which take the third parameter and return multiplication of arguments which is being passed in successive

In JavaScript function defined inside has access to outer function variable and function is the first class object so it can be returned by function as well and passed as argument in another function.

  • A function is an instance of the Object type
  • A function can have properties and has a link back to its constructor method
  • Function can be stored as variable
  • Function can be pass as a parameter to another function
  • Function can be returned from function

Q9 :   Write a function that would allow you to do this?

You can create a closure to keep the value passed to the function createBase even after the inner function is returned. The inner function that is being returned is created within an outer function, making it a closure, and it has access to the variables within the outer function, in this case the variable baseNumber .

Q10 :   FizzBuzz Challenge

Create a for loop that iterates up to 100 while outputting "fizz" at multiples of 3 , "buzz" at multiples of 5 and "fizzbuzz" at multiples of 3 and 5 .

Check out this version of FizzBuzz:

Q11 :   Given two strings, return true if they are anagrams of one another

For example: Mary is an anagram of Army

Q12 :   How would you use a closure to create a private counter?

You can create a function within an outer function (a closure) that allows you to update a private variable but the variable wouldn't be accessible from outside the function without the use of a helper function.

Q13 :   Provide some examples of non-bulean value coercion to a boolean one

The question is when a non-boolean value is coerced to a boolean, does it become true or false , respectively?

The specific list of "falsy" values in JavaScript is as follows:

  • "" (empty string)
  • 0 , -0 , NaN (invalid number)
  • null , undefined

Any value that's not on this "falsy" list is "truthy." Here are some examples of those:

  • [ ] , [ 1, "2", 3 ] (arrays)
  • { } , { a: 42 } (objects)
  • function foo() { .. } (functions)

Q14 :   What will be the output of the following code?

Above code would give output 1undefined . If condition statement evaluate using eval so eval(function f() {}) which return function f() {} which is true so inside if statement code execute. typeof f return undefined because if statement code execute at run time, so statement inside if condition evaluated at run time.

Above code will also output 1undefined .

Q15 :   What will the following code output?

The code above will output 5 even though it seems as if the variable was declared within a function and can't be accessed outside of it. This is because

is interpreted the following way:

But b is not declared anywhere in the function with var so it is set equal to 5 in the global scope .

Q16 :   Write a function that would allow you to do this

You can create a closure to keep the value of a even after the inner function is returned. The inner function that is being returned is created within an outer function, making it a closure, and it has access to the variables within the outer function, in this case the variable a .

Q17 :   How does the this keyword work? Provide some code examples

In JavaScript this always refers to the “owner” of the function we're executing, or rather, to the object that a function is a method of.

Q18 :   How would you create a private variable in JavaScript?

To create a private variable in JavaScript that cannot be changed you need to create it as a local variable within a function. Even if the function is executed the variable cannot be accessed outside of the function. For example:

To access the variable, a helper function would need to be created that returns the private variable.

Q19 :   What is Closure in JavaScript? Provide an example

A closure is a function defined inside another function (called parent function) and has access to the variable which is declared and defined in parent function scope.

The closure has access to variable in three scopes:

  • Variable declared in his own scope
  • Variable declared in parent function scope
  • Variable declared in global namespace

innerFunction is closure which is defined inside outerFunction and has access to all variable which is declared and defined in outerFunction scope. In addition to this function defined inside function as closure has access to variable which is declared in global namespace .

Output of above code would be:

Q20 :   What will be the output of the following code?

Above code will output 0 as output. delete operator is used to delete a property from an object. Here x is not an object it's local variable . delete operator doesn't affect local variable.

Q21 :   What will be the output of the following code?

Above code will output xyz as output. Here emp1 object got company as prototype property. delete operator doesn't delete prototype property.

emp1 object doesn't have company as its own property. You can test it like:

However, we can delete company property directly from Employee object using delete Employee.company or we can also delete from emp1 object using __proto__ property delete emp1.__proto__.company .

Q22 :   What will the following code output?

This will surprisingly output false because of floating point errors in internally representing certain numbers. 0.1 + 0.2 does not nicely come out to 0.3 but instead the result is actually 0.30000000000000004 because the computer cannot internally represent the correct number. One solution to get around this problem is to round the results when doing arithmetic with decimal numbers.

Q23 :   When would you use the bind function?

The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.

A good use of the bind function is when you have a particular function that you want to call with a specific this value. You can then use bind to pass a specific object to a function that uses a this reference.

Q24 :   Write a recursive function that performs a binary search

Q25 :   describe the revealing module pattern design pattern.

A variation of the module pattern is called the Revealing Module Pattern . The purpose is to maintain encapsulation and reveal certain variables and methods returned in an object literal. The direct implementation looks like this:

An obvious disadvantage of it is unable to reference the private methods

Rust has been Stack Overflow’s most loved language for four years in a row and emerged as a compelling language choice for both backend and system developers, offering a unique combination of memory safety, performance, concurrency without Data races...

Clean Architecture provides a clear and modular structure for building software systems, separating business rules from implementation details. It promotes maintainability by allowing for easier updates and changes to specific components without affe...

Azure Service Bus is a crucial component for Azure cloud developers as it provides reliable and scalable messaging capabilities. It enables decoupled communication between different components of a distributed system, promoting flexibility and resili...

FullStack.Cafe is a biggest hand-picked collection of top Full-Stack, Coding, Data Structures & System Design Interview Questions to land 6-figure job offer in no time.

Coded with 🧡 using React in Australia 🇦🇺

by @aershov24 , Full Stack Cafe Pty Ltd 🤙, 2018-2023

Privacy • Terms of Service • Guest Posts • Contacts • MLStack.Cafe

coding problem solving interview questions

  • C++ Data Types
  • C++ Input/Output
  • C++ Pointers
  • C++ Interview Questions
  • C++ Programs
  • C++ Cheatsheet
  • C++ Projects
  • C++ Exception Handling
  • C++ Memory Management
  • 30 OOPs Interview Questions and Answers (2024)
  • C++ Interview Questions and Answers (2024)

Top 100 C++ Coding Interview Questions and Answers (2024)

  • Top 50+ Python Interview Questions and Answers (Latest 2024)
  • Java Interview Questions and Answers
  • Java Collections Interview Questions and Answers
  • Top 20 Java Multithreading Interview Questions & Answers
  • Top 100 Data Structure and Algorithms DSA Interview Questions Topic-wise
  • Top 50 Array Coding Problems for Interviews
  • Most Asked Problems in Data Structures and Algorithms | Beginner DSA Sheet
  • Top 10 Algorithms in Interview Questions
  • Machine Learning Interview Questions
  • Top 50 Problems on Linked List Data Structure asked in SDE Interviews
  • Top 50 Problems on Heap Data Structure asked in SDE Interviews
  • Data Analyst Interview Questions and Answers
  • SQL Query Interview Questions
  • Top Linux Interview Questions With Answer
  • MySQL Interview Questions
  • Top 50 Django Interview Questions and Answers
  • Top 50 Networking Interview Questions (2024)
  • Software Testing Interview Questions

C++ is one of the most popular languages in the software industry for developing software ranging from operating systems, and DBMS to games. That is why it is also popular to be asked to write C++ Programs in live coding sessions in job placement interviews.

Cpp-coding-Questions---Answers

This article provides a list of C++ coding interview questions for beginners as well as experienced professionals. The questions are designed to test candidates’ understanding of the following topics:

  • C++ syntax and semantics
  • Data structures and algorithms
  • Object-oriented programming
  • Memory management

List of 100 C++ Coding Interview Questions and Answers

Here is a list of 100 C++ coding interview questions and answers

1. Write a C++ Program to Check Whether a Number is a Positive or Negative Number.

2. write a program to find the greatest of the three numbers., 3. c++ program to check whether number is even or odd.

For more information, refer to the article – C++ Program To Check Whether Number is Even Or Odd

4. Write a Program to Find the ASCII Value of a Character

5. write a program to check whether a character is a vowel or consonant, 6. write a program to print check whether a character is an alphabet or not, 7. write a program to find the length of the string without using strlen() function , 8. write a program to toggle each character in a string , 9. write a program to count the number of vowels , 10. write a program to remove the vowels from a string, 11. write a program to remove all characters from a string except alphabets, 12. write a program to remove spaces from a string, 13. write a program to find the sum of the first n natural numbers, 14. write a program to find the factorial of a number using loops, 15. write a program to find a leap year or not, 16. write a program to check the prime number, 17. write a program to check palindrome, 18. write a program to check whether a number is an armstrong number or not, 19. write a program to find the nth term of the fibonacci series, 20. write a program to calculate the greatest common divisor of two numbers, 21. write a program to calculate the lowest common multiple (lcm) of two numbers,   22. write a program for finding the roots of a quadratic equation, 23. write a program to find the smallest and largest element in an array, 24. write a program to find the second smallest element in an array, 25. write a program to calculate the sum of elements in an array, 26. write a program to check if the given string is palindrome or not, 27. write a program to check if two strings are anagram or not, 28. write a program to print a diamond pattern, 29. write a program to print a pyramid pattern, 30. write a program to print the hourglass pattern, 31. write a program to print the rotated hourglass pattern, 32. write a program to print a simple pyramid pattern, 33. write a program to print an inverted pyramid , 34. write a program to print a triangle star pattern, 35. write a program to print floyd’s triangle, 36. write a program to print the pascal triangle, 37. write a program to print the given string in reverse order , 38. write a c++ program to print the given string in reverse order using recursion, 39. write a program to check if the given string is palindrome or not using recursion, 40. write a program to calculate the length of the string using recursion, 41. write a program to calculate the factorial of a number using recursion, 42. write a program to count the sum of numbers in a string, 43. write a program to print all natural numbers up to n without using a semi-colon, 44. write a program to  swap the values of two variables without using any extra variable, 45. write a program to print the maximum value of an unsigned int using one’s complement (~) operator, 46. write a program to check for the equality of two numbers without using arithmetic or comparison operator, 47. write a program to find the maximum and minimum of the two numbers without using the comparison operator, 48. write a program for octal to decimal conversion, 49. write a program for hexadecimal to decimal conversion, 50. write a program for decimal to binary conversion, 51. write a program for decimal octal conversion, 52. write a program for decimal to hexadecimal conversion, 53. write a program for binary to octal conversion , 54. write a program for octal to binary conversion  , 55. write a program to implement the use of encapsulation, 56. write a program to implement the concept of abstraction, 57. write a program to implement the concept of compile-time polymorphism or function overloading, 58. write a program to implement the concept of operator overloading, 59. write a program to implement the concept of function overriding or runtime polymorphism, 60. write a program to implement single-level inheritance, 61. write a program to create a class for complex numbers, 62. write a program to implement the inch feet system, 63. write a program to implement bubble sort, 64. write a program to implement insertion sort, 65. write a program to implement selection sort, 66. write a program to implement merge sort, 67. write a program to implement quick sort, 68. write a program to implement linear search, 69. write a program to implement binary search, 70. write a program to find the index of a given element in a vector, 71. write a program to remove duplicate elements in an array using stl, 72. write a program to sort an array in descending order using stl, 73. write a program to calculate the frequency of each word in the given string, 74. write a program to find k maximum elements of an array in the original order, 75. write a program to find all unique subsets of a given set using stl, 76. write a program to iterate over a queue without removing the element, 77. write a program for the implementation of stacks using an  array, 78. write a program for the implementation of a queue using an array, 79. write a program implementation of stacks using a queue, 80. write a program to implement a stack using the list in stl, 81. write a program to determine array is a subset of another array or not, 82. write a program for finding the circular rotation of an array by k positions, 83. write a program to sort the first half in ascending order and the second half in descending, 84. write a program to print the given string in reverse order, 85. write a program to print all permutations of a string using recursion, 86. write a program to print all permutations of a given string in lexicographically sorted order, 87. write a program to remove brackets from an algebraic expression, 88. program to perform insert, delete, and print operations singly linked list, 89. program to perform insert, delete, and print operations doubly linked list, 90. program to perform insert, delete, and print operations circular linked list, 91. program for inorder traversal in a binary tree, 92. program to find all its subsets from a set of positive integers, 93. program for preorder traversal in a binary tree, 94. program for postorder traversal in a binary tree, 95. program for level-order traversal in a binary tree, 96. write a program for the top view of a binary tree, 97. write a program to print the bottom view of a binary tree, 98. write a program to print the left view of a binary tree, 99. write a program to print the right view of the binary tree, 100. write a program for the conversion of infix expression to postfix expression.

Coding interviews can be challenging task, but they are also a great opportunity to test your skills and knowledge. By practicing with commonly ask C++ coding interview questions , you can increase your chances of success.

Remember to stay calm, communicate your thought process clearly, and don’t be afraid to ask for clarification if needed. With hard work and preparation, you can ace your interview and land your dream job!

C++ Coding Interview Questions – FAQs

Q: what are the most common c++ coding interview questions.

The most common C++ coding interview questions are designed to test your knowledge of the following topics: C++ syntax and semantics Data structures and algorithms Object-oriented programming Memory management Pointers Templates & More.

Q: What should I do during a C++ coding interview?

When you are asked a coding question in an interview, take a moment to think about the problem before you start coding. Explain your thought process to the interviewer as you are coding. This will help them to understand your approach to solving problems.

Q: What are some tips for writing clean and efficient code?

Here are some tips for writing clean and efficient code: Use meaningful variable names. Use whitespace to make your code readable. Break down complex problems into smaller, more manageable problems. Use comments to explain your code. Test your code thoroughly. Use appropriate data structures and algorithms. Avoid unnecessary duplication of code.

Q: How can I improve my communication skills during C++ coding interviews?

Here are some tips for improving your communication skills during C++ coding interviews: Speak clearly and concisely. Explain your thought process to the interviewer. Ask clarifying questions if needed. Be prepared to answer questions about your code. Be open to feedback. Practicing explaining your code to others is a great way to improve your communication skills. You can also practice by giving yourself mock interviews.

Please Login to comment...

Similar reads.

  • interview-questions

advertisewithusBannerImg

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

DEV Community

DEV Community

Let's Code

Posted on Jan 5, 2022 • Updated on Jan 6, 2022

10 ReactJS Coding Challenge (💥Coding Interview Prep💥)

Last month, I posted 2 ReactJS interview questions 🎤 - Advance Questions and Commonly Asked Question and got a significant welcome by dev.to community. 🤗 🥰 Many thanks to all of you!

I decided to complete the package by creating codepen exercises 📝 and a video 📺 to follow up on that effort as one will need to code following the technical interview questions. Also, I added potential solutions for the exercises which is listed below.

If you need to brush up 🆙 your ninja ReactJS skills, you can try to answer the exercises below OR click the video below to guide you step-by-step interactively. (No filler, fast, straight to the point as I highly respect/value your time)

These exercises and solutions will also be available on the video as well.

Exercises: 🏋️

Display simple jsx.

  • https://codepen.io/angelo_jin/pen/wvrygZa

Display array of users to browser

  • https://codepen.io/angelo_jin/pen/QWqQdXE

Show/Hide Element on Screen

  • https://codepen.io/angelo_jin/pen/zYERZZL

2 way data binding in ReactJS

  • https://codepen.io/angelo_jin/pen/MWEQmqN

Disable a button

  • https://codepen.io/angelo_jin/pen/YzrazGY

Update the parent state

  • https://codepen.io/angelo_jin/pen/JjrLjOy

Dynamically add child components (React Children)

  • https://codepen.io/angelo_jin/pen/BawrpeX

Sum of Two Numbers

  • https://codepen.io/angelo_jin/pen/zYEWZNR

Create Counter App

  • https://codepen.io/angelo_jin/pen/mdBxWwN

Fetch data from an API

  • https://codepen.io/angelo_jin/pen/oNGqZpm

Solutions: 🙋

  • https://codepen.io/angelo_jin/pen/xxXrZLd
  • https://codepen.io/angelo_jin/pen/wvreMpZ
  • https://codepen.io/angelo_jin/pen/abLwyrL
  • https://codepen.io/angelo_jin/pen/yLzvMop
  • https://codepen.io/angelo_jin/pen/dyVmyYz
  • https://codepen.io/angelo_jin/pen/KKXoKgO
  • https://codepen.io/angelo_jin/pen/MWEVJNb
  • https://codepen.io/angelo_jin/pen/BawrWzy

Create Counter App 🕒

  • https://codepen.io/angelo_jin/pen/yLzKMXX
  • https://codepen.io/angelo_jin/pen/zYEWZdW

Happy coding and good luck on your next interview! I hope this material will help you land your next dream job. 💰 🚗 📈

Top comments (38)

pic

Templates let you quickly answer FAQs or store snippets for re-use.

armenic profile image

  • Location Toronto, Canada
  • Education Masters in epidemiology
  • Work Senior Applicaiton Developer at F. Hoffmann-La Roche
  • Joined Dec 29, 2020

Thanks for nice challenges. I really enjoyed solving them! By the way beta.reactjs.org/ also started to include challenges. Maybe you can contribute to the new docs? They are open for public PRs.

frontendengineer profile image

  • Work Software Engineer
  • Joined May 6, 2019

your welcome! ill definitely check that out. thanks for the link.👏🏻👍

lovishtater profile image

  • Location Pune, India
  • Work Software Engineer at Source.one
  • Joined Dec 3, 2020

Hi armenic, I want to contribute new challenges in beta.reactjs.org/. I don't know how to contribute, I saw React's git repo but I didn't understand how to start. can you please guide me.

check this out - reactjs.org/docs/how-to-contribute...

mkmckenzie profile image

  • Education UNC Chapel Hill
  • Work Lead Engineer I @ Stitch Fix
  • Joined May 26, 2022

Great exercises! Had fun with these!!

One thing I want to note - in your solutions, I often see the pattern:

However, the React docs prefer this method of using the previous state value - passing a function that receives the previous state value.

Updating state with value instead of using the previous state function may result in some buggy behavior because of React's unpredictable & async state-updating logic. Likely won't see anything buggy with these examples since they aren't too complex, but just wanted to shout out that nuance!

Thanks again for these great exercises!!

yes, passing a function is way better and the right approach to handle setting state here. Glad that you found this post useful and you are very welcome. Will create more post/video like again.

cssmatter profile image

  • Joined Jul 4, 2023

I found this on udemy. React JS Coding Interview Challenges and Exercises udemy.com/course/react-js-coding-i...

replay profile image

  • Joined Jan 24, 2022

Nice I always look for those kind of challenges to practice

i plan on making more in the future. Stay tuned :)

sandyml profile image

  • Joined Sep 28, 2022

I enjoyed this! Thank you so much!!! If anyone have anything similar please share! I would love to tackle on some more! Thank you in advance!

you are welcome!

belle1306 profile image

  • Joined Feb 23, 2021

For create counter app challenge, i created two functions (decrease and increase) to be passed instead, later simply calling ....is that inline with best practise?

it is and is common in any ReactJS applications

abbydorso profile image

  • Work software engineer
  • Joined May 25, 2022

this is so helpful for interview prep, thank you!!

helping engineers like you and me are the goal of this post and video.

I appreciate the comment and stay tuned for more post like this.

aliafify profile image

  • Work Developer
  • Joined Apr 3, 2022

thanks for that nice chalanges

your welcome buddy! i feel great that this content helps many devs. 👍

veronicamarie24 profile image

  • Joined Mar 18, 2022

This was so helpful, thank you!

your welcome Veronica! check the youtube video i have above for additional reference. Many found it useful as well.

techspace profile image

  • Education AMC Engineering College
  • Work Trainee
  • Joined Mar 15, 2022

It's difficult for beginners (like me) to directly dive into building projects after learning React from online tutorials. Thanks for these practice problems, need more of these on React. :)

ive been there before and i know how you feel. i’ll try to find more time and do more. i’ll post when i have something ready. thanks for the comment

pcoch profile image

  • Location Brisbane, Australia
  • Education QUT
  • Work Shopify
  • Joined Jan 8, 2022

Out of curiosity, if you could do all of these quite easily without any external help/docs, is that a good sign you might be ready for a React Junior Dev role? 🤔 Or would we need to be answering the advanced ones?

this is question is more tailored for experienced/advanced React Dev.

you can expect basic Q&A for React Junior Dev and small react exercises

urmajesty516 profile image

  • Joined Sep 23, 2018

I found these exercises are too easy. Could you please mention that these are for absolute beginners somewhere in the header of the post? I doubt that any interview question would be this straight forward. Nevertheless, appreciate your effort on making the post, it has to be useful for someone 👏🏻

ersankarimi profile image

  • Location Balikpapan
  • Education Institut Teknologi Kalimantan
  • Pronouns Ersan
  • Joined Dec 15, 2021

For me (beginner), this is very helpful and gives an overview of the interview later. Thank you for sharing

absolutely! what is your status currently? are you in the job market?

anandbaraik profile image

  • Joined Jun 30, 2018

Good job man. Intresting exercises.

thank you Anand! What is your favorite exercise and why? Or perhaps anything that you would like to see on the challenge.

greenjscoder profile image

  • Joined Dec 14, 2023

too easy for interview, look real example https://stackblitz.com/edit/stackblitz-starters-rqq4bw?description=A%20create-react-app%20project%20based%20on%20react%20and%20react-dom&file=src%2FApp.js,src%2Findex.js&title=React%20Starter you can make that all works as expected, but wont pass interview because of interviewer wants you write some functions in other way

and you can forget some things because of worrying

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink .

Hide child comments as well

For further actions, you may consider blocking this person and/or reporting abuse

mattbrailsford profile image

Creating your own UI extension points in Umbraco v14 - Part 1: The Basics

Matt Brailsford - Apr 2

prathamdupare profile image

API Routes in Next.js - Part 4

Pratham Dupare - Apr 2

gcascio profile image

Dynamic breadcrumbs in Next.js using the app router

gcascio - Apr 1

hoangguruu profile image

DevOps with Guruu | Chapter 18 : Build and Deploy DevSecOps Chatbot Use generative AI [ Full ]

Hoang Guruu - Apr 2

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Table of Contents

Coding interview questions on conceptual understanding, programming interview questions, choose the right software development program, get ahead of the curve and master programming today, top 40 coding interview questions you should know.

Top 40 Coding Interview Questions You Should Know

Programming questions are an integral part of an interview for the developer's position. No matter which programming language you master, familiarity with fundamental concepts of programming is something that is always expected from you.

Coding skills are always the deciding factor in any programming interview. In this coding interview questions article, we will discuss the top 40 Coding Interview Questions you should absolutely know to crack those interviews and get your dream job.

So without further ado, let’s get started!

Watch the video below that deals with real-time and corporate-level programming-based interview questions and answers.

The coding interview questions addresses in this article are grouped into 2 categories (as below) to make your learning simpler.

  • Conceptual Interview Questions

We will now look at the first category of coding interview questions. 

This section covers some coding interview questions that test the conceptual understanding of the candidate.

1. What is a Data Structure?

  • A data structure is a storage format that defines the way data is stored, organized, and manipulated.
  • Some popular data structures are Arrays, Trees, and Graphs.

Become a Software Development Professional

Full stack java developer.

  • Kickstart Full Stack Java Developer career with industry-aligned curriculum by experts
  • Hands-on practice through 20+ projects, assessments, and tests

Full Stack Web Developer - MEAN Stack

  • Comprehensive Blended Learning program
  • 8X higher interaction in live online classes conducted by industry experts

2. What is an Array?

  • An array is commonly referred to as a collection of items stored at contiguous memory locations.
  • Items stored are of the same type.
  • It organizes data so that a related set of values can be easily sorted or searched.

array string

3. What is a Linked List?

  • Like an array, a linked list refers to a linear data structure in which the elements are not necessarily stored in a contiguous manner.
  • It is basically a sequence of nodes, each node points towards the next node forming a chain-like structure.

linked list

Fig: Linked List

4. What is LIFO?

  • LIFO is an abbreviation for Last In First Out
  • It is a way of accessing, storing and retrieving data.
  • It extracts the data that was stored last first.

5. What is a Stack?

  • A stack refers to a linear data structure performing operations in a LIFO (Last In First Out) order.
  • In a stack, elements can only be accessed, starting from the topmost to the bottom element.

6. What is FIFO?

  • FIFO stands for First In First Out.
  • The data that was stored first is extracted first.

lifo fifo

Fig: LIFO, FIFO

Till now, you’ve covered some very fundamental coding interview questions. Going ahead you will dive deeper into the subject.

7. What is a Queue?

  • A queue refers to a linear data structure that performs operations in a FIFO order.
  • In a queue, the least recently added elements are removed first as opposed to a stack. 

queue

8. What are Binary Trees?

  • A binary tree is an extension of the linked list structure where each node has at most two children. 
  • A binary tree has two nodes at all times, a left node and a right node.

binary-tees

Fig: Binary Trees

9. What is Recursion?

  • Recursion refers to a function calling itself based on a terminating condition.
  • It uses LIFO and therefore makes use of the stack data structure.

The next couple of coding interview questions will explore your knowledge of OOPs.

10. What is the OOPs concept?

OOPs stands for Object-Oriented Programming System, a paradigm that provides concepts such as objects, classes, and inheritance.

11. What are the concepts introduced in OOPs?

Following are the concepts introduced in OOPs:

  • Object - A real-world entity having a particular state and behavior. We can define it as an instance of a class.
  • Class - A logical entity that defines the blueprint from which an object can be created or instantiated.
  • Inheritance - A concept that refers to an object gaining all the properties and behaviors of a parent object. It provides code reusability.
  • Polymorphism - A concept that allows a task to be performed in different ways. In Java, we use method overloading and method overriding to achieve polymorphism.
  • Abstraction - A concept that hides the internal details of an application and only shows the functionality. In Java, we use abstract class and interface to achieve abstraction.
  • Encapsulation - A concept that refers to the wrapping of code and data together into a single unit.

This is one of the very common coding interview questions, that often allows the interviewer to branch out into related topics based on the candidate’s answers

12. Explain what a Binary Search Tree is.

  • A binary search tree is used to store data in a manner that it can be retrieved very efficiently. 
  • The left sub-tree contains nodes whose keys are less than the node’s key value.
  • The right sub-tree contains nodes whose keys are greater than or equal to the node’s key value

binary search

Fig: Binary Search Tree

13. Explain Doubly Linked Lists?

  • Doubly linked lists are categorized as a special type of linked list in which traversal across the data elements can be done in both directions. 
  • This is made possible by the presence of two links in every node, one that links to the node next to it and another that connects to the node before it.

doubly link

Fig: Doubly Linked List

14. What is a Graph?

  • A graph is a particular type of data structure that contains a set of ordered pairs.
  • The ordered pairs in a graph are also known as edges or arcs and are most commonly used to connect nodes where the data can be stored and retrieved.

15. Differentiate between linear and non-linear data structure?

16. what is a deque.

  • A deque is a double-ended queue.
  • This is a structure in which elements can be inserted or removed from either end.

17. What’s the difference between Stack and Array ?

18. which sorting algorithm is the best.

  • There are many types of sorting algorithms: bubble sort, quick sort, balloon sort, merge sort, radix sort, and more.
  • No algorithm can be considered as the best or fastest because they have designed each for a specific type of data structure where it performs the best

19. How does variable declaration affect memory?

  • The amount of memory that is to be reserved or allocated depends on the data type being stored in that variable. 
  • For example, if a variable is declared to be “integer type”, 32 bits of memory storage will then be reserved for that particular variable.

20. What are dynamic data structures?

Dynamic data structures have the feature where they expand and contract as a program runs. It provides a very flexible method of data manipulation because adjusts based on the size of the data to be manipulated.

These 20 coding interview questions that test the conceptual understanding of the candidates give the interview a clear idea on how strong the candidate’s fundamentals are

The next set of coding interview questions focus tests the programming expertise of the candidates and dives deep into various related aspects.

The code screenshots given along with the below coding interview questions helps you provide the answer to the question, with clarity.

21. How do you reverse a string in Java?

  • Declare a string.
  • Take out the length of that string.
  • Loop through the characters of the string.
  • Add the characters in reverse order in the new string.

22. How do you determine if a string is a palindrome?

  • A string is a palindrome when it stays the same on reversing the order of characters in that string.
  • It can be achieved by reversing the original string first and then checking if the reversed string is equal to the original string.

23. Find the number of occurrences of a character in a String?

To find the number of occurrences, loop through the string and search for that character at every iteration; whenever it is found, it will update the count.

24. How to find out if the given two strings are anagrams or not?

Two strings are anagrams if they contain a similar group of characters in a varied sequence.

  • Declare a boolean variable that tells at the end of the two strings are anagrams or not.
  • First, check if the length of both strings is the same, if not, they cannot be anagrams.
  • Convert both the strings to character arrays and then sort them.
  • Check if the sorted arrays are equal. If they are equal, print anagrams, otherwise not anagrams. 

boolean anagrmstat = false;

if (str.length() != reverse.length()) {

    System.out.println(str + " and " + reverse + " not anagrams string");

    char[] anagram1 = str.toCharArray();

    char[] anagram2 = reverse.toCharArray();

    Arrays.sort(anagram1);

    Arrays.sort(anagram2);

    anagrmstat = Arrays.equals(anagram1, anagram2);

if (anagrmstat == true) {

    System.out.println(" anagrams string");

    System.out.println(" not anagrams string");

25. How do you calculate the number of vowels and consonants in a String?

  • Loop through the string.
  • Increase the vowel variable by one whenever the character is found to be a vowel, using the if condition. Otherwise, increment the consonant variable.
  • Print the values of both the vowel and the consonant count.

int vowels = 0;

int consonants = 0;

for (int k = 0; k < str.length(); k++) {

    char c = str.charAt(k);

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')

        vowels++;

        consonants++;

System.out.println("Vowel count is " + vowels);

System.out.println("Consonant count is: " + consonants);

26. How do you get the matching elements in an integer array?

  • Declare an array.
  • Nest a couple of loops to compare the numbers with other numbers in the array.
  • Print the matching elements if found.

int[] a = { 1, 2, 3, 4, 5, 1, 2, 6, 7 };

for (int m = 0; m < a.length; m++) {

    for (int n = m + 1; n < a.length; n++) {

        if (a[m] == a[n])

            System.out.print(a[m]);

27. How would you implement the bubble sort algorithm?

  • Nest a couple of loops to compare the numbers in the array.
  • The array will be sorted in ascending order by replacing the elements if found in any other order.

int[] a = { 1, 2, 7, 6, 4, 9, 12 };

for (int k = 0; k < a.length; k++) {

    for (int l = 0; l < a.length - l - 1; l++) {

        if (a[l] > a[l + 1]) {

            int t = a[l];

            a[l] = a[l + 1];

            a[l + 1] = t;

Learn the top skills in-demand including Angular, Spring Boot, JSPs, and SOA to build highly web scalable apps with the Full Stack Java Developer Masters Program .

28. How would you implement the insertion sort algorithm?

  • We assume the first element in the array to be sorted. The second element is stored separately in the key. This sorts the first two elements. You can then take the third element and do a comparison with the ones on the left of it. This process will go on until a point where we sort the array.

for (int m = 1; m < a.length; m++) {

    int n = m;

    while (n > 0 && a[n - 1] > a[n]) {

        int k = a[n];

        a[n] = a[n - 1];

        a[n - 1] = k;

        n--;

29. How do you reverse an array?

  • Loop till the half-length of the array.
  • Replace the numbers corresponding to the indexes from the starting and the end.

for (int t = 0; t < a.length / 2; t++) { 

    int tmp = a[t]; 

    a[t] = a[a.length - t - 1]; 

    a[a.length - t- 1] = tmp; 

30. How would you swap two numbers without using a third variable?

  • Declare two variables and initialize them with values.
  • Make b the sum of both numbers.
  • Then subtract the sum (b) from a, so a is now swapped.
  • Lastly, subtract a from the sum (b), so b is also swapped.

int a = 10;

int b = 20;

b = b + a; // now b is sum of both the numbers

a = b - a; // b - a = (b + a) - a = b (a is swapped)

b = b - a; // (b + a) - b = a (b is swapped)

31. Print a Fibonacci series using recursion?

  • The Fibonacci numbers are the numbers in the following integer sequence:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..

  • We can calculate them using the mathematical formula used in the Fibonacci recursive function.

public static int fibonacci(int n) {

    if (n <= 1)

        return n;

    return fibonacci(n - 1) + fibonacci(n - 2);

public static void main(String args[]) {

    int n = 10;

    System.out.println(fibonacci(n));

32. How do you find the factorial of an integer?

  • A factorial is a function that multiplies a number by every number below it. For example, 5!= 5*4*3*2*1=120.
  • Recursive function multiples the numbers until it reaches 1.

public static long factorial(long n) {

if (n == 1)

    return 1;

    return (n * factorial(n - 1));

33. How do you reverse a Linked List?

  • Declare a linked list.
  • Add elements to that linked list.
  • Apply the descending iterator method to the linked list.
  • This reverses the order of elements in the linked list.

LinkedList<Integer> ll = new LinkedList<>();

System.out.println(ll);

LinkedList<Integer> ll1 = new LinkedList<>();

ll.descendingIterator().forEachRemaining(ll1::add);

System.out.println(ll1);

34. How would you implement Binary Search?

  • Binary search divides the array into half in every iteration step until it finds the element.
  • It works on the sorted arrays since it compares the values of adjacent elements and then calculates the mid number.
  • If the value of low becomes greater than high at any point, it means the element is not present in the list.

int mid = (low + high) / 2;

while (low <= high) {

    if (arr[mid] < key) {

        low = mid + 1;

    } else if (arr[mid] == key) {

        return mid;

    } else {

        high = mid - 1;

    mid = (low + high) / 2;

if (low > high) {

    return -1;

35. How would you find the second largest number in an array?

  • Loop through the array.
  • If the value of i is greater than the highest, store the value of i in highest, and store the value of highest in the second-highest variable.

private static int findSecondHighest(int[] array) {

    int highest = Integer.MIN_VALUE;

    int secondHighest = Integer.MIN_VALUE;

    for (int i : array) {

        if (i > highest) {

            secondHighest = highest;

            highest = i;

        } else if (i > secondHighest) {

            secondHighest = i;

    return secondHighest;

36. How do you remove all occurrences of a given character from the input string?

  • Use the built-in string method “replace” to replace a character with any other character, including symbols and white spaces.

String str1 = "Australia";

str1 = str1.replace("a", "");

System.out.println(str1); // ustrli

37. Showcase Inheritance with the help of a program?

  • The class Cat inherits the property color from the class Animal by extending the parent class (Animal).
  • This way a class Cat can have more parent classes if it wishes to inherit their properties.

class Animal {

    String color;

class Cat extends Animal {

    void meow() {

        System.out.println("Meow");

38. Explain overloading and overriding with the help of a program?

Overloading:

When a class has two or more methods with the same name, they are called overloaded methods.

class Foo {

    void print(String s) {

        System.out.println(s);

    void print(String s, int count) {

        while (count > 0) {

            System.out.println(s);

            count--;

Overriding:

When a superclass method is also implemented in the child class, it’s a case of overriding.

class Base {

    void printName() {

        System.out.println("Base Class");

class Child extends Base {

    @Override

        System.out.println("Child Class");

39. How do you check if the given number is prime?

  • Use if statements to check for each condition separately:
  • If the number is 0 or 1, it cannot be prime.
  • If the number is 2, it is prime number.
  • If the number is indivisible by other numbers, it is prime.

public static boolean isPrime(int n) {

    if (n == 0 || n == 1) {

        return false;

    if (n == 2) {

        return true;

    for (int i = 2; i <= n / 2; i++) {

        if (n % i == 0) {

            return false;

    return true;

40. How do you sum all the elements in an array?

  • Use for loop to iterate through the array and keep adding the elements in that array.

int[] array = { 1, 2, 3, 4, 5 };

int sum = 0;

for (int i : array)

    sum += i;

System.out.println(sum);

As you get prepared for your job interview, we hope that these Coding Interview Questions have provided more insight into what types of questions you are likely to come across.

This table compares various courses offered by Simplilearn, based on several key features and details. The table provides an overview of the courses' duration, skills you will learn, additional benefits, among other important factors, to help learners make an informed decision about which course best suits their needs.

Program Name Full Stack Java Developer Automation Testing Masters Program Geo IN All University Simplilearn Simplilearn Course Duration 6 Months 11 Months Coding Experience Required Basic Knowledge Basic Knowledge Skills You Will Learn 15+ Skills Including Core Java, SQL, AWS, ReactJS, etc. Java, AWS, API Testing, TDD, etc. Additional Benefits Interview Preparation Exclusive Job Portal 200+ Hiring Partners Structured Guidance Learn From Experts Hands-on Training Cost $$ $$ Explore Program Explore Program

Now that you are well-versed with the top Coding Interview Questions, you should be seeking out opportunities to gain the skills you need to leverage the immense popularity of software development and build a successful career in it. Well, you needn’t look any further. We have got your back! Our comprehensive  Full Stack Developer Course  will help you with the necessary skills and more that you need and help you become career-ready upon completion. 

If you are looking for more information, do check out our YouTube video that further explains these coding interview questions and answers, and helps you become more confident while appearing for the interview processes.

Embarking on a journey to become a full-fledged full stack developer involves diving into a broad range of coding concepts, from frontend technologies like HTML, CSS, and JavaScript, to backend systems including server, database, and application logic. To ensure you're well-prepared for your coding interviews, consider enrolling in a full stack developer course that covers essential interview questions and provides comprehensive training.

Do you have any questions for us? Well, feel free to mention them in the comments section of this “Top 40 Coding Interview Questions’’ article. Our subject matter experts will review and answer them for you soon.

Our Software Development Courses Duration And Fees

Software Development Course typically range from a few weeks to several months, with fees varying based on program and institution.

Recommended Reads

Kubernetes Interview Guide

Top R Programming Interview Questions and Answers

180+ Core Java Interview Questions and Answers for 2024

Apache Spark Interview Guide

Top Meta (Facebook) Interview Questions and Answers for 2024

Top 100+ Git Interview Questions [2024]: Crack the Code

Get Affiliated Certifications with Live Class programs

Automation testing masters program.

  • Comprehensive blended learning program
  • 200 hours of Applied Learning
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.

Top 20 Problem Solving Interview Questions (Example Answers Included)

Mike Simpson 0 Comments

coding problem solving interview questions

By Mike Simpson

When candidates prepare for interviews, they usually focus on highlighting their leadership, communication, teamwork, and similar crucial soft skills . However, not everyone gets ready for problem-solving interview questions. And that can be a big mistake.

Problem-solving is relevant to nearly any job on the planet. Yes, it’s more prevalent in certain industries, but it’s helpful almost everywhere.

Regardless of the role you want to land, you may be asked to provide problem-solving examples or describe how you would deal with specific situations. That’s why being ready to showcase your problem-solving skills is so vital.

If you aren’t sure who to tackle problem-solving questions, don’t worry, we have your back. Come with us as we explore this exciting part of the interview process, as well as some problem-solving interview questions and example answers.

What Is Problem-Solving?

When you’re trying to land a position, there’s a good chance you’ll face some problem-solving interview questions. But what exactly is problem-solving? And why is it so important to hiring managers?

Well, the good folks at Merriam-Webster define problem-solving as “the process or act of finding a solution to a problem.” While that may seem like common sense, there’s a critical part to that definition that should catch your eye.

What part is that? The word “process.”

In the end, problem-solving is an activity. It’s your ability to take appropriate steps to find answers, determine how to proceed, or otherwise overcome the challenge.

Being great at it usually means having a range of helpful problem-solving skills and traits. Research, diligence, patience, attention-to-detail , collaboration… they can all play a role. So can analytical thinking , creativity, and open-mindedness.

But why do hiring managers worry about your problem-solving skills? Well, mainly, because every job comes with its fair share of problems.

While problem-solving is relevant to scientific, technical, legal, medical, and a whole slew of other careers. It helps you overcome challenges and deal with the unexpected. It plays a role in troubleshooting and innovation. That’s why it matters to hiring managers.

How to Answer Problem-Solving Interview Questions

Okay, before we get to our examples, let’s take a quick second to talk about strategy. Knowing how to answer problem-solving interview questions is crucial. Why? Because the hiring manager might ask you something that you don’t anticipate.

Problem-solving interview questions are all about seeing how you think. As a result, they can be a bit… unconventional.

These aren’t your run-of-the-mill job interview questions . Instead, they are tricky behavioral interview questions . After all, the goal is to find out how you approach problem-solving, so most are going to feature scenarios, brainteasers, or something similar.

So, having a great strategy means knowing how to deal with behavioral questions. Luckily, there are a couple of tools that can help.

First, when it comes to the classic approach to behavioral interview questions, look no further than the STAR Method . With the STAR method, you learn how to turn your answers into captivating stories. This makes your responses tons more engaging, ensuring you keep the hiring manager’s attention from beginning to end.

Now, should you stop with the STAR Method? Of course not. If you want to take your answers to the next level, spend some time with the Tailoring Method , too.

With the Tailoring Method, it’s all about relevance. So, if you get a chance to choose an example that demonstrates your problem-solving skills, this is really the way to go.

We also wanted to let you know that we created an amazing free cheat sheet that will give you word-for-word answers for some of the toughest interview questions you are going to face in your upcoming interview. After all, hiring managers will often ask you more generalized interview questions!

Click below to get your free PDF now:

Get Our Job Interview Questions & Answers Cheat Sheet!

FREE BONUS PDF CHEAT SHEET: Get our " Job Interview Questions & Answers PDF Cheat Sheet " that gives you " word-word sample answers to the most common job interview questions you'll face at your next interview .

CLICK HERE TO GET THE JOB INTERVIEW QUESTIONS CHEAT SHEET

Top 3 Problem-Solving-Based Interview Questions

Alright, here is what you’ve been waiting for: the problem-solving questions and sample answers.

While many questions in this category are job-specific, these tend to apply to nearly any job. That means there’s a good chance you’ll come across them at some point in your career, making them a great starting point when you’re practicing for an interview.

So, let’s dive in, shall we? Here’s a look at the top three problem-solving interview questions and example responses.

1. Can you tell me about a time when you had to solve a challenging problem?

In the land of problem-solving questions, this one might be your best-case scenario. It lets you choose your own problem-solving examples to highlight, putting you in complete control.

When you choose an example, go with one that is relevant to what you’ll face in the role. The closer the match, the better the answer is in the eyes of the hiring manager.

EXAMPLE ANSWER:

“While working as a mobile telecom support specialist for a large organization, we had to transition our MDM service from one vendor to another within 45 days. This personally physically handling 500 devices within the agency. Devices had to be gathered from the headquarters and satellite offices, which were located all across the state, something that was challenging even without the tight deadline. I approached the situation by identifying the location assignment of all personnel within the organization, enabling me to estimate transit times for receiving the devices. Next, I timed out how many devices I could personally update in a day. Together, this allowed me to create a general timeline. After that, I coordinated with each location, both expressing the urgency of adhering to deadlines and scheduling bulk shipping options. While there were occasional bouts of resistance, I worked with location leaders to calm concerns and facilitate action. While performing all of the updates was daunting, my approach to organizing the event made it a success. Ultimately, the entire transition was finished five days before the deadline, exceeding the expectations of many.”

2. Describe a time where you made a mistake. What did you do to fix it?

While this might not look like it’s based on problem-solving on the surface, it actually is. When you make a mistake, it creates a challenge, one you have to work your way through. At a minimum, it’s an opportunity to highlight problem-solving skills, even if you don’t address the topic directly.

When you choose an example, you want to go with a situation where the end was positive. However, the issue still has to be significant, causing something negative to happen in the moment that you, ideally, overcame.

“When I first began in a supervisory role, I had trouble setting down my individual contributor hat. I tried to keep up with my past duties while also taking on the responsibilities of my new role. As a result, I began rushing and introduced an error into the code of the software my team was updating. The error led to a memory leak. We became aware of the issue when the performance was hindered, though we didn’t immediately know the cause. I dove back into the code, reviewing recent changes, and, ultimately, determined the issue was a mistake on my end. When I made that discovery, I took several steps. First, I let my team know that the error was mine and let them know its nature. Second, I worked with my team to correct the issue, resolving the memory leak. Finally, I took this as a lesson about delegation. I began assigning work to my team more effectively, a move that allowed me to excel as a manager and help them thrive as contributors. It was a crucial learning moment, one that I have valued every day since.”

3. If you identify a potential risk in a project, what steps do you take to prevent it?

Yes, this is also a problem-solving question. The difference is, with this one, it’s not about fixing an issue; it’s about stopping it from happening. Still, you use problem-solving skills along the way, so it falls in this question category.

If you can, use an example of a moment when you mitigated risk in the past. If you haven’t had that opportunity, approach it theoretically, discussing the steps you would take to prevent an issue from developing.

“If I identify a potential risk in a project, my first step is to assess the various factors that could lead to a poor outcome. Prevention requires analysis. Ensuring I fully understand what can trigger the undesired event creates the right foundation, allowing me to figure out how to reduce the likelihood of those events occurring. Once I have the right level of understanding, I come up with a mitigation plan. Exactly what this includes varies depending on the nature of the issue, though it usually involves various steps and checks designed to monitor the project as it progresses to spot paths that may make the problem more likely to happen. I find this approach effective as it combines knowledge and ongoing vigilance. That way, if the project begins to head into risky territory, I can correct its trajectory.”

17 More Problem-Solving-Based Interview Questions

In the world of problem-solving questions, some apply to a wide range of jobs, while others are more niche. For example, customer service reps and IT helpdesk professionals both encounter challenges, but not usually the same kind.

As a result, some of the questions in this list may be more relevant to certain careers than others. However, they all give you insights into what this kind of question looks like, making them worth reviewing.

Here are 17 more problem-solving interview questions you might face off against during your job search:

  • How would you describe your problem-solving skills?
  • Can you tell me about a time when you had to use creativity to deal with an obstacle?
  • Describe a time when you discovered an unmet customer need while assisting a customer and found a way to meet it.
  • If you were faced with an upset customer, how would you diffuse the situation?
  • Tell me about a time when you had to troubleshoot a complex issue.
  • Imagine you were overseeing a project and needed a particular item. You have two choices of vendors: one that can deliver on time but would be over budget, and one that’s under budget but would deliver one week later than you need it. How do you figure out which approach to use?
  • Your manager wants to upgrade a tool you regularly use for your job and wants your recommendation. How do you formulate one?
  • A supplier has said that an item you need for a project isn’t going to be delivered as scheduled, something that would cause your project to fall behind schedule. What do you do to try and keep the timeline on target?
  • Can you share an example of a moment where you encountered a unique problem you and your colleagues had never seen before? How did you figure out what to do?
  • Imagine you were scheduled to give a presentation with a colleague, and your colleague called in sick right before it was set to begin. What would you do?
  • If you are given two urgent tasks from different members of the leadership team, both with the same tight deadline, how do you choose which to tackle first?
  • Tell me about a time you and a colleague didn’t see eye-to-eye. How did you decide what to do?
  • Describe your troubleshooting process.
  • Tell me about a time where there was a problem that you weren’t able to solve. What happened?
  • In your opening, what skills or traits make a person an exceptional problem-solver?
  • When you face a problem that requires action, do you usually jump in or take a moment to carefully assess the situation?
  • When you encounter a new problem you’ve never seen before, what is the first step that you take?

Putting It All Together

At this point, you should have a solid idea of how to approach problem-solving interview questions. Use the tips above to your advantage. That way, you can thrive during your next interview.

FREE : Job Interview Questions & Answers PDF Cheat Sheet!

Download our " Job Interview Questions & Answers PDF Cheat Sheet " that gives you word-for-word sample answers to some of the most common interview questions including:

  • What Is Your Greatest Weakness?
  • What Is Your Greatest Strength?
  • Tell Me About Yourself
  • Why Should We Hire You?

Click Here To Get The Job Interview Questions & Answers Cheat Sheet

coding problem solving interview questions

Co-Founder and CEO of TheInterviewGuys.com. Mike is a job interview and career expert and the head writer at TheInterviewGuys.com.

His advice and insights have been shared and featured by publications such as Forbes , Entrepreneur , CNBC and more as well as educational institutions such as the University of Michigan , Penn State , Northeastern and others.

Learn more about The Interview Guys on our About Us page .

About The Author

Mike simpson.

' src=

Co-Founder and CEO of TheInterviewGuys.com. Mike is a job interview and career expert and the head writer at TheInterviewGuys.com. His advice and insights have been shared and featured by publications such as Forbes , Entrepreneur , CNBC and more as well as educational institutions such as the University of Michigan , Penn State , Northeastern and others. Learn more about The Interview Guys on our About Us page .

Copyright © 2024 · TheInterviewguys.com · All Rights Reserved

  • Our Products
  • Case Studies
  • Interview Questions
  • Jobs Articles
  • Members Login

coding problem solving interview questions

Codility Logo

Programming Problem-Solving Interview Questions You Should Ask

Be the first to know.

Sign up for a weekly dose of tech hiring news and updates.

At Codility, we create coding assessments for hiring software developers.

This implies that we also hire developers to create technical interviews for hiring developers. It is like two-star pointers or programming squared.

Our interview process consists of a Codility coding assessment in the front, and then a good old technical interview for the candidates who prove they have the coding knowledge and fundamentals in the back. I want to share four technical interview tips and questions that we use to assess competencies in programming during a video interview, using CodeLive.

Coding assessments and remote technical interviews

1. Scalability & Optimization

If you are planning to do something big, it will need to scale well in this way or another. A basic understanding of scalability is assessed by an automated Codility assessment .

During the technical interview process, we ask candidates to answer a simple programming problem-solving question which has multiple solutions with different simplicity/scalability trade-offs (e.g. compute prefix sums of a sequence of numbers). We assess whether a candidate notices the scalability aspect and whether he/she can deliver the working solution with better scalability.

Time permitting we probe deeper, asking “can it possibly be done better?” This question opens discussions about possible optimizations, sometimes going down to the hardware level, but also about intrinsic limitations of computing machinery, which greatly illustrates whether candidate a can apply theory to a concrete problem.

2. Aliasing – Pointers & References

In the interview process, we usually ask candidates to answer a simple programming problem-solving question that involves pointers/references, like manipulations on single-link lists. As much as we rarely deal with direct lists manipulation nowadays, we believe it shows whether a candidate can deal with real-life scenarios where multiple levels of indirection occur e.g. in data models. (And as David Wheeler used to say, “All problems in computer science can be solved by another level of indirection, except of course for the problem of too many indirections.”)

3. Recursion – Be Mentally Prepared

Understanding and handling recursion is a sign of a programmer’s fitness, and this should be a key component of any coding assessment.

On some jobs this skill will be crucial, on other jobs maybe not so much, but the fact that a candidate knows how to do it shows that they’ve been doing mental push-ups and sit-downs long enough to be ready to take the triathlon challenge and showcase their strength throughout the interview process.

The classic moderate question here is to take a simple recursive function and ask the candidate to rewrite it into an iterative one.

4. Communication – Be Clear & Concise

Coding is not only a way of communicating your requirements to the machine, but also a way of communicating your intent to fellow team members.

For each programming exercise the candidates solve, both on the automated Codility coding assessments, online CodeLive video interview, and in face-to-face interviews, we look at the code they write and assess whether it speaks to us clearly. If you look at the code and you immediately know what’s going on, that’s a plus, if you don’t that’s a red flag.

Greg is the founder and principal scientist at Codility.

Connect on LinkedIn

IMAGES

  1. How to solve coding interview questions 2 ("Let's leetcode")

    coding problem solving interview questions

  2. 10 Common Coding Interview Problems [Solved]

    coding problem solving interview questions

  3. 8 Problem-Solving Interview Questions You Should Ask

    coding problem solving interview questions

  4. Coding Interview Questions And Answers

    coding problem solving interview questions

  5. 45 Common Coding Interview Questions

    coding problem solving interview questions

  6. 7-Step Approach to Solve Any Coding Problem (Important for Interviews)

    coding problem solving interview questions

VIDEO

  1. JS Problem Solving Questions 01

  2. Print Digits In Descending Order in Java

  3. My Interview experience with Oracle

  4. 2D Prefix Sum Interview Pattern

  5. 10 Strategies to Improve Your Problem Solving Skills #shorts

  6. Python Interview Questions and Answers

COMMENTS

  1. 40 Coding Challenges (SOLVED with CODE) To Kill Your Next Coding

    You may hate code challenges and coding interviews but reality is a lot of companies from Google to Amazon do care that you understand the difference between `O(n log n)` and `O(n²)`, that you do understand _when_ different data structures are appropriate, and that you can leverage these (very basic) skills to solve simple problems. Follow along and check 40 most common Coding Challenges and ...

  2. 100+ Coding Interview Questions for Programmers and ...

    Grokking the Coding Interview: Patterns for Coding Questions by 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 problem using patterns. Master these 15 underlying patterns to interview ...

  3. 15 Common Problem-Solving Interview Questions

    Here are a few examples of technical problem-solving questions: 1. Mini-Max Sum. This well-known challenge, which asks the interviewee to find the maximum and minimum sum among an array of given numbers, is based on a basic but important programming concept called sorting, as well as integer overflow.

  4. Problems

    Boost your coding interview skills and confidence by practicing real interview questions with LeetCode. Our platform offers a range of essential problems for practice, as well as the latest questions being asked by top-tier companies. ... Interview. Store Study Plan. See all. Array 1614. String 686. Hash Table 576. Math 492. Dynamic Programming ...

  5. 64 Coding Interview Questions + Answers [2024 Prep Guide]

    64 Coding Interview Questions + Answers [2024 Prep Guide] No matter your experience level, coding interviews are always difficult to prepare for. That's why we've compiled this comprehensive list of coding interview questions you're likely to be asked. This guide covers technical questions with Python and C# snippets, concept-based ...

  6. 22 Coding Interview Questions Every Developer Should Know

    Web Developer Interview Questions: An Overview. Coding interview questions — sometimes called coding challenges — ask developers to write code to find an answer to a problem. Depending on the role and company, coding questions can be language-specific or allow developers to respond in their coding language of choice.

  7. 10 Common Coding Interview Problems [Solved]

    Learn how to solve 10 common coding problems often used in interviews, such as valid anagram, sorted array, and symmetric tree, with graphics and animation. Watch a 2-hour course on the freeCodeCamp.org YouTube channel developed by an experienced developer.

  8. Top techniques to approach and solve coding interview questions

    When given a coding interview question, candidates should start by asking clarifying questions and discussing a few possible approaches with their interviewers. However, this is where most candidates tend to get stuck. ... Solving the problem by hand is about solving the problem without writing any code, like how a non-programmer would. This ...

  9. How To Solve Coding Interview Questions (An Ultimate Guide)

    1. Understand The Provided Question. The first step to solving a coding interview problem is to understand the provided question you're asked. If you don't fully understand the question before you start thinking about and coding solutions then you're automatically going to fail to solve the problem.

  10. Cracking the Coding Interview: Solve 5 Real World Problems

    In order to crack the coding interview, problem-solving skills are just as necessary as technical skills. Identify the problem type, break it into smaller parts, and develop a plan for solving it. Creative problem-solving is at the core of every developer, and the interviewer wants to see you demonstrate it.

  11. 45 Common Coding Interview Questions

    M: Match the problem with the interviewer. P: Plan your approach and solution. I: Implement your solution. R: Review your solution. E: Evaluate your solution. To prepare for a whiteboard challenge, "practice talking through your problem-solving process ," says Archie Payne, president of CalTek Staffing, an IT and technical staffing firm.

  12. JavaScript Coding Interview Practice

    Interview Question 1: How to Get Passengers' Names. Let's get the passengers' names as requested. The first solution is through a 'for loop' method. So we first need to use an empty array to push the passengers' names right inside it at the end of the loop.

  13. Top 20 Algorithms Problems for Coding Interviews with Solutions

    Btw, if you find this question tough to solve, I suggest you take a look at the Grokking the Coding Interview: Patterns for Coding Questions course on Educative, an interactive portal for coding ...

  14. Python Practice Problems: Get Ready for Your Next Interview

    That's it! You've walked through a solution for the sudoku solver problem. Interview Discussion Topics. The sudoku solver solution you just walked through is a good deal of code for an interview situation. Part of an interview process would likely be to discuss some of the code and, more importantly, some of the design trade-offs you made.

  15. 73+ real-life interview questions for development & coding roles

    Software Engineers design, develop, and maintain software applications, applying coding expertise and problem-solving skills. They collaborate within Agile processes, understand API communication, utilize data structures, and optimize code performance. Here are 25 interview questions from real hiring managers with sample answers for each:

  16. Top 34 C# Coding Interview Questions (SOLVED) To Crack Your Tech

    Strings 25. Being powerful, flexible, and well-supported has meant C# has quickly become one of the most popular programming languages available. Today, it is the 4th most popular programming language, with approximately 31% of all developers using it regularly. Follow along and check 34 most common C# Coding Interview Questions (SOLVED) for ...

  17. Top 26 coding questions to crack the Microsoft interview

    Problem Statement: Given an array of integers and a value, determine if there are any two integers in the array whose sum is equal to the given value. Return true if the sum exists, and false if it does not. Consider the following array and its target sums: 5 7 1 2 8 4 3. Target Sum 10 7+3=10, 2+8=10.

  18. 25+ JavaScript Coding Interview Questions (SOLVED with CODE)

    FullStack.Cafe is a biggest hand-picked collection of top Full-Stack, Coding, Data Structures & System Design Interview Questions to land 6-figure job offer in no time. Check 25+ JavaScript Coding Interview Questions (SOLVED with CODE) and Land Your Next Six-Figure Job Offer! 100% Tech Interview Success!

  19. 8 Common Problem-Solving Interview Questions and Answers

    Problem-solving interview questions are questions that employers ask related to the candidate's ability to gather data, analyze a problem, weigh the pros and cons and reach a logical decision. ... Top 10 Programming/Coding Interview Questions. Common Personality Questions Asked in an Interview (And What They Reveal) Explore more articles.

  20. Top 100 C++ Coding Interview Questions and Answers (2024)

    This article provides a list of C++ coding interview questions for beginners as well as experienced professionals. The questions are designed to test candidates' understanding of the following topics: C++ syntax and semantics. Data structures and algorithms. Object-oriented programming.

  21. 10 ReactJS Coding Challenge ( Coding Interview Prep )

    Job Interview Preparation Materials (22 Part Series) 1 JavaScript Interview Questions and Answers you should know - Junior and Senior 2 CSS and HTML Interview Questions and Answers [2022] ... 18 more parts... 21 CSS Interview Question: Create Responsive Design (1 Column / 3 Column) 22 CSS Interview Question: Center HTML Element (3 Approaches ...

  22. Top 40 Coding Interview Questions You Should Know

    This is one of the very common coding interview questions, that often allows the interviewer to branch out into related topics based on the candidate's answers. 12. Explain what a Binary Search Tree is. A binary search tree is used to store data in a manner that it can be retrieved very efficiently.

  23. Top 20 Problem Solving Interview Questions (Example Answers Included)

    MIKE'S TIP: When you're answering this question, quantify the details. This gives your answer critical context and scale, showcasing the degree of challenge and strength of the accomplishment. That way, your answer is powerful, compelling, and, above all, thorough. 2. Describe a time where you made a mistake.

  24. Programming Problem-Solving Interview Questions You Should Ask

    4. Communication - Be Clear & Concise. Coding is not only a way of communicating your requirements to the machine, but also a way of communicating your intent to fellow team members. For each programming exercise the candidates solve, both on the automated Codility coding assessments, online CodeLive video interview, and in face-to-face ...