Top 100 Coding Interview Questions for 2025: Java, Python, DSA

List of 100+ key coding interview questions in Java, Python, JavaScript, and DSA. Perfect for freshers and experienced developers to ace their coding interview.

Mentor

Blog

You've probably been there - scrolling through endless websites, trying to figure out what coding questions might pop up in your next interview.

LeetCode has over 3,500 problems. Codeforces has 2,000+. And GeeksforGeeks?... you might get lost before you even find what you need..

It’s easy to get overwhelmed.

Should you focus on arrays? Do you need to learn every sorting algorithm? πŸ€”

This guide cuts through all that noise. We've gathered the most commonly asked coding interview questions that actually show up in real interviews - from big tech companies to startups.

Whether you're a fresh graduate or someone switching careers, these are the questions that keep appearing again and again.

What you'll find inside πŸ‘‡

↳ Types of coding interview questions

↳ Top Java, Python, and JavaScript coding questions

↳ Must-know DSA problems

↳ Conceptual coding questions

↳ FAQs and next steps

Let’s get started!

Types of Coding Interview Questions

Before we dive into the actual questions, let's understand what interviewers are really looking for. Most coding questions fall into these three buckets:

β˜‘οΈ Problem-Solving Questions: These test how you break down complex problems. Think of questions like "find the missing number in an array" or "check if a string is a palindrome."

β˜‘οΈ Data Structure Questions: Here, they want to see if you know when to use arrays, linked lists, stacks, or trees. It's not just about knowing what they are, but picking the right tool for the job.

β˜‘οΈ Algorithm Questions: These focus on your ability to implement sorting, searching, and other fundamental algorithms. They're testing if you understand the "how" behind the code.

Top Java Coding Interview Questions

Java remains one of the most popular languages for technical interviews. Here are the questions that come up most frequently:

🟒 Array and String Problems

  1. Reverse an array without using extra space
    1. Find the largest and smallest element in an array
      1. Remove duplicates from a sorted array
        1. Check if two strings are anagrams
          1. Find the first non-repeating character in a string
            1. Merge two sorted arrays
              1. Find the missing number in an array from 1 to N

                🟒 Object-Oriented Programming

                1. Explain inheritance with a real-world example
                  1. What's the difference between method overloading and overriding?
                    1. Build a basic class inheritance structure like Animal β†’ Dog β†’ Bulldog
                      1. Implement a basic calculator using OOP principles

                        🟒 Collections and Data Structures

                        1. Implement a stack using arrays
                          1. Implement a linked list that supports inserting and deleting nodes
                            1. Use a hash map to track how many times each character appears in a string
                              1. Find the intersection of two arrays

                                🟒 Multithreading and Concurrency

                                1. Create two threads that print numbers alternately
                                  1. Explain synchronization with a simple example
                                    1. What happens when multiple threads access the same variable?

                                      🟒 Exception Handling

                                      1. Write a program that handles multiple exceptions
                                        1. Create custom exceptions for a banking application

                                          Most Java interviewers love asking about collections, so make sure you're comfortable with ArrayList, HashMap, and HashSet. They also tend to focus on OOP concepts - be ready to explain inheritance, polymorphism, and encapsulation with simple examples.

                                          πŸ“Œ Want to practice these Java questions with step-by-step guidance?

                                          Here’s a free MentorAI coding chrome extension that walks you through each solution, points out mistakes, and helps you write cleaner, faster code, just like companies expect.

                                          It’s really simple to use: download β†’ pin to your browser β†’ start solving.

                                          Top Python Coding Interview Questions

                                          Here are the Python questions that you need to practice:

                                          🟠 List and Dictionary Operations

                                          1. Find the second largest number in a list
                                            1. Count the frequency of elements in a list
                                              1. Merge two dictionaries
                                                1. Find common elements between two lists
                                                  1. Remove duplicates from a list while preserving order
                                                    1. Flatten a nested list

                                                      🟠 String Manipulation

                                                      1. Check if a string is a palindrome (ignore spaces and case)
                                                        1. Count vowels and consonants in a string
                                                          1. Find the longest word in a sentence
                                                            1. Replace all spaces in a string with '%20'

                                                              🟠 Functions and Decorators

                                                              1. Write a decorator that measures function execution time
                                                                1. Create a function that returns another function (closure)
                                                                  1. Implement a simple caching decorator

                                                                    🟠 File Handling and Exceptions

                                                                    1. Read a CSV file and find the average of a column
                                                                      1. Handle file not found exceptions gracefully
                                                                        1. Count how many lines are present in a text file

                                                                          🟠 Data Processing

                                                                          1. Identify the word that appears most frequently in a file
                                                                            1. Group a list of dictionaries by a specific key
                                                                              1. Calculate the factorial of a number (both recursive and iterative)
                                                                                1. Generate the Fibonacci sequence up to N terms

                                                                                  Python interviewers often ask about list comprehensions, so practice writing clean, readable code. They also love questions about data processing since Python is widely used for data analysis.

                                                                                  πŸ“Œ But how do you make sure your solutions are clean, efficient, and ready for interviews?

                                                                                  β†’ This free coding assistant can help you do that.

                                                                                  Download it for free and start practising these Python problems with personalised hints!

                                                                                  8000+ developers use it daily to master these exact problems.

                                                                                  Top JavaScript Coding Interview Questions

                                                                                  JavaScript interviews can be tricky because they mix programming logic with web-specific concepts. Here's what comes up most often:

                                                                                  🟑 Array and Object Manipulation

                                                                                  1. Find the sum of all numbers in an array
                                                                                    1. Remove duplicates from an array using Set
                                                                                      1. Find the intersection of two arrays
                                                                                        1. Group objects by a specific property
                                                                                          1. Flatten a nested array
                                                                                            1. Sort an array of objects by a property

                                                                                              🟑 String and Number Problems

                                                                                              1. Check if a string is a palindrome
                                                                                                1. Count how often each character appears in a given string
                                                                                                  1. Find the longest word in a sentence
                                                                                                    1. Convert a string to title case
                                                                                                      1. Generate a random number between two values

                                                                                                        🟑 Functions and Scope

                                                                                                        1. Explain hoisting with an example
                                                                                                          1. Create a closure that maintains a counter
                                                                                                            1. Write a function that returns another function
                                                                                                              1. Implement a simple calculator using functions

                                                                                                                🟑 Asynchronous Programming

                                                                                                                1. Use setTimeout to delay execution
                                                                                                                  1. Convert callback to Promise
                                                                                                                    1. Handle multiple API calls with Promise.all
                                                                                                                      1. Basic async/await example

                                                                                                                        🟑 DOM and Browser Concepts

                                                                                                                        1. Change text content of an HTML element
                                                                                                                          1. Add event listeners to buttons
                                                                                                                            1. Create and append new elements to the page
                                                                                                                              1. Get form input values and validate them

                                                                                                                                JavaScript interviews often focus on understanding how the language works (hoisting, closures, scope) rather than complex algorithms.

                                                                                                                                πŸ“Œ Now, these concepts can be tricky to grasp at first. Our AI coding mentor breaks down complex topics like closures and async programming into simple steps.

                                                                                                                                It's completely free, super easy to use, and works alongside LeetCode to help you understand the "why" behind each solution. ✨

                                                                                                                                Download it and start practising now!

                                                                                                                                Essential DSA Questions to Practice

                                                                                                                                These are the bread and butter of coding interviews. No matter what language you use, these concepts are universal:

                                                                                                                                πŸ“Array Problems

                                                                                                                                1. Two Sum: Find two numbers that add up to a target
                                                                                                                                  1. Best Time to Buy and Sell Stock
                                                                                                                                    1. Rotate an array by K positions
                                                                                                                                      1. Find the maximum subarray sum (Kadane's Algorithm)
                                                                                                                                        1. Search in a rotated sorted array

                                                                                                                                          πŸ“Linked List Questions

                                                                                                                                          1. Reverse a linked list
                                                                                                                                            1. Detect if a linked list has a cycle
                                                                                                                                              1. Find the middle element of a linked list
                                                                                                                                                1. Merge two sorted linked lists
                                                                                                                                                  1. Remove the Nth node from the end

                                                                                                                                                    πŸ“Tree and Graph Problems

                                                                                                                                                    1. Binary tree traversal (inorder, preorder, postorder)
                                                                                                                                                      1. Find the height of a binary tree
                                                                                                                                                        1. Check if a binary tree is balanced
                                                                                                                                                          1. Lowest common ancestor of two nodes
                                                                                                                                                            1. Breadth-first search (BFS) implementation
                                                                                                                                                              1. Depth-first search (DFS) implementation

                                                                                                                                                                πŸ“Sorting and Searching

                                                                                                                                                                1. Implement quicksort
                                                                                                                                                                  1. Implement merge sort
                                                                                                                                                                    1. Binary search in a sorted array
                                                                                                                                                                      1. Find the Kth largest element in an array

                                                                                                                                                                        πŸ“Dynamic Programming (For Advanced Roles)

                                                                                                                                                                        1. Fibonacci sequence using memoization
                                                                                                                                                                          1. Longest common subsequence
                                                                                                                                                                            1. 0/1 Knapsack problem
                                                                                                                                                                              1. Coin change problem

                                                                                                                                                                                πŸ“Hash Tables and Sets

                                                                                                                                                                                1. Design a hash map from scratch
                                                                                                                                                                                  1. Identify all pairs in an array whose sum matches a given number
                                                                                                                                                                                    1. Group anagrams together

                                                                                                                                                                                      The key to solving DSA questions is recognising patterns. Most problems are variations of these classic questions, so understanding the underlying approach is more crucial than memorising specific solutions.

                                                                                                                                                                                      Here’s a FREE coding chrome extension that helps you build these skills.

                                                                                                                                                                                      It provides real-time feedback, spots inefficiencies, optimises your space and time complexity, and guides you to catch edge cases you might miss.

                                                                                                                                                                                      Plus, it integrates seamlessly with popular platforms like LeetCode and HackerRank, so you get instant help right where you practice. πŸ’―

                                                                                                                                                                                      Important Conceptual Questions

                                                                                                                                                                                      These theory-based questions test your understanding of programming fundamentals. Don't just memorise answers - make sure you can explain them simply:

                                                                                                                                                                                      πŸ”΅ Time and Space Complexity

                                                                                                                                                                                      1. What is Big O notation? Give examples
                                                                                                                                                                                        1. Compare the time complexity of different sorting algorithms
                                                                                                                                                                                          1. What's the difference between O(1), O(n), and O(log n)?
                                                                                                                                                                                            1. How do you calculate space complexity?

                                                                                                                                                                                              πŸ”΅ Data Structures Theory

                                                                                                                                                                                              1. How do you decide between using an array or a linked list?
                                                                                                                                                                                                1. Explain the difference between stack and queue
                                                                                                                                                                                                  1. What are the advantages of using a hash table?
                                                                                                                                                                                                    1. In what scenarios does a binary tree work better than an array?
                                                                                                                                                                                                      1. How are trees and graphs different from each other?

                                                                                                                                                                                                        πŸ”΅ Object-Oriented Programming

                                                                                                                                                                                                        1. Explain inheritance with a real-world example
                                                                                                                                                                                                          1. What's the difference between abstraction and encapsulation?
                                                                                                                                                                                                            1. When would you use composition over inheritance?
                                                                                                                                                                                                              1. What is polymorphism? Give a simple example

                                                                                                                                                                                                                πŸ”΅ Memory Management

                                                                                                                                                                                                                1. What's the difference between stack and heap memory?
                                                                                                                                                                                                                  1. Explain garbage collection in simple terms
                                                                                                                                                                                                                    1. What causes memory leaks and how to avoid them?

                                                                                                                                                                                                                      πŸ”΅ Programming Fundamentals

                                                                                                                                                                                                                      1. What's the difference between pass by value and pass by reference?
                                                                                                                                                                                                                        1. Explain recursion and when to use it
                                                                                                                                                                                                                          1. What are the pros and cons of using global variables?
                                                                                                                                                                                                                            1. What's the difference between compile time and runtime errors?

                                                                                                                                                                                                                              πŸ”΅ Database and System Concepts

                                                                                                                                                                                                                              1. What is database normalization?
                                                                                                                                                                                                                                1. Explain the difference between SQL and NoSQL
                                                                                                                                                                                                                                  1. What is an API and how does it work?
                                                                                                                                                                                                                                    1. What's the difference between HTTP and HTTPS?

                                                                                                                                                                                                                                      These questions often come up in the middle of coding rounds when interviewers want to test your theoretical knowledge.

                                                                                                                                                                                                                                      Practice explaining these concepts in simple terms, as if you're teaching someone new to programming.

                                                                                                                                                                                                                                      Coding Interview Questions for Freshers

                                                                                                                                                                                                                                      If you're just starting out, don't worry - companies know you're new to this. Here are the questions most commonly asked to fresh graduates:

                                                                                                                                                                                                                                      🟣 Programming Fundamentals

                                                                                                                                                                                                                                      1. Write a program to check if a number is prime
                                                                                                                                                                                                                                        1. Print the multiplication table of a given number
                                                                                                                                                                                                                                          1. Find the factorial of a number
                                                                                                                                                                                                                                            1. Check if a year is a leap year
                                                                                                                                                                                                                                              1. Convert temperature from Celsius to Fahrenheit

                                                                                                                                                                                                                                                🟣 Basic Data Structures

                                                                                                                                                                                                                                                1. Implement a simple stack with push, pop, and peek operations
                                                                                                                                                                                                                                                  1. Create a basic queue with enqueue and dequeue
                                                                                                                                                                                                                                                    1. Linear search in an array
                                                                                                                                                                                                                                                      1. Find the largest element in an array

                                                                                                                                                                                                                                                        🟣 Simple Algorithms

                                                                                                                                                                                                                                                        1. Bubble sort implementation
                                                                                                                                                                                                                                                          1. Selection sort step-by-step
                                                                                                                                                                                                                                                            1. Binary search (if the array is sorted)

                                                                                                                                                                                                                                                              🟣 Object-Oriented Concepts

                                                                                                                                                                                                                                                              1. Create a Student class with basic properties
                                                                                                                                                                                                                                                                1. Demonstrate inheritance with a simple example
                                                                                                                                                                                                                                                                  1. Show method overloading with different parameters

                                                                                                                                                                                                                                                                    🟣 Basic Problem Solving

                                                                                                                                                                                                                                                                    1. Sum of digits in a number
                                                                                                                                                                                                                                                                      1. Reverse a number
                                                                                                                                                                                                                                                                        1. Check if a string is a palindrome
                                                                                                                                                                                                                                                                          1. Count the number of words in a sentence
                                                                                                                                                                                                                                                                            1. Find the GCD of two numbers

                                                                                                                                                                                                                                                                              Remember, as a fresher, they're more interested in your problem-solving approach than perfect optimisation. Focus on writing understandable code and explaining your thought process clearly.

                                                                                                                                                                                                                                                                              🎯 Ready to start practising?

                                                                                                                                                                                                                                                                              Knowing the questions is just the start. The real challenge is solving them well during interviews.

                                                                                                                                                                                                                                                                              Most people can solve problems on paper. But in interviews, they make small mistakes, miss optimisations, or forget to check special cases. This is where many candidates fail.

                                                                                                                                                                                                                                                                              Your Practice Partner: MentorAI Extension

                                                                                                                                                                                                                                                                              It helps you practice these coding interview questions the right way. It's like having a coding teacher right beside you while you solve problems.

                                                                                                                                                                                                                                                                              What it does for you:

                                                                                                                                                                                                                                                                              βœ… Gives feedback while you code: Catch mistakes early

                                                                                                                                                                                                                                                                              βœ… Shows better solutions: Write cleaner, faster code

                                                                                                                                                                                                                                                                              βœ… Finds edge cases: Don't miss tricky parts

                                                                                                                                                                                                                                                                              βœ… Works on all popular coding sites: No more hopping between tutorials or losing momentum.

                                                                                                                                                                                                                                                                              βœ… Easy explanations: Perfect for beginners

                                                                                                                                                                                                                                                                              Over 8,000 engineers use MentorAI every day to get better at coding and land great tech jobs. They practice smarter, not just harder.

                                                                                                                                                                                                                                                                              Ready to level up your coding practice?

                                                                                                                                                                                                                                                                              Frequently Asked Questions

                                                                                                                                                                                                                                                                              Q. What kind of coding questions are asked in an interview?

                                                                                                                                                                                                                                                                              Most interviews include a mix of algorithmic problems (like array manipulation and tree traversal), data structure questions (implementing stacks, queues), and problem-solving challenges. The difficulty varies based on the company and your experience level.

                                                                                                                                                                                                                                                                              Q. How many coding questions should I practice?

                                                                                                                                                                                                                                                                              Focus on understanding patterns rather than memorising solutions. Practising 100-150 well-chosen problems across different categories is usually enough. Quality over quantity - make sure you truly understand each solution.

                                                                                                                                                                                                                                                                              Q. What if I can't solve a problem during the interview?

                                                                                                                                                                                                                                                                              Stay calm and think out loud. Ask for hints, discuss your approach, and try to get a partial solution working. Interviewers often care more about your problem-solving process than getting the perfect answer.

                                                                                                                                                                                                                                                                              Q. Should I focus on one programming language?

                                                                                                                                                                                                                                                                              Yes, pick one language and get really comfortable with it. Java and Python are popular choices because they have clean syntax and good library support.

                                                                                                                                                                                                                                                                              Q. How should a beginner start coding?

                                                                                                                                                                                                                                                                              Start with basics first. Pick one language and learn the simple stuff - variables, loops, and functions. Don't jump to hard problems right away.

                                                                                                                                                                                                                                                                              Here's a good plan:

                                                                                                                                                                                                                                                                              βœ“ Learn basic syntax for 2-3 weeks

                                                                                                                                                                                                                                                                              βœ“ Try easy problems on LeetCode or HackerRank

                                                                                                                                                                                                                                                                              βœ“ Focus on understanding, not speed

                                                                                                                                                                                                                                                                              βœ“ Practice every day, even if it's just 30 minutes

                                                                                                                                                                                                                                                                              Q. Where can I get the solution to these coding questions?

                                                                                                                                                                                                                                                                              You can find solutions on platforms like LeetCode, HackerRank, and GeeksforGeeks. But just reading solutions won't help much. You need to understand the thinking behind each solution.

                                                                                                                                                                                                                                                                              And that's where MentorAI Chrome Extension helps. It is perfect for beginners. It gives you simple explanations when you get stuck and helps you understand why your code works or doesn't work.

                                                                                                                                                                                                                                                                              It works on all major coding platforms and gives you the kind of help that makes you actually learn, not just copy answers. βœ…

                                                                                                                                                                                                                                                                              πŸ‘‰ Download this free AI Coding extension and start solving problems like a pro.