Java Interview Questions: Data Structures and Algorithms

Refresh your Java knowledge and solve new problems with the most common beginner interview questions asked by FANG companies.

The Best Java Interview Guide

Learn the most commonly asked questions by the likes of Facebook, Google, Amazon and Spotify for beginners.

Preparing for the Java interview is hard. You need to understand not only concepts but also be able to articulate your thought process as you plan and execute a solution.

In this course, you'll learn the best way to answer an interview question, look at the most commonly asked questions, and analyze time complexity of various algorithms.

You'll learn through hands-on coding examples and learn to solve problems quickly.


COURSE BREAKDOWN

Java Interview Questions: Data Structures and Algorithms

Section 0: Introduction to Interview Questions

  • Course Overview
  • FizzBuzz: Print the numbers from 1 to 100 and for multiples of '3' print "Fizz" instead of the number and for the multiples of '5' print "Buzz".

Section 1: String/Array Interview Questions

  • 01 Reverse Words in a String: Given an input string, reverse the string word by word.
  • 02 Rotate Array: Rotate an array of n elements to the left by k steps.
  • 03 Isomorphic Strings: Given two strings a and b, determine if they are isomorphic.
  • 04 Kth Largest Element in an Array: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.

Section 2: Matrix Interview Questions

  • 01 Set Matrix Zeroes: Given a 2D matrix, if an element is 0, set its entire row and column to 0. Do it in place.
  • 02 Spiral Matrix: Given a 2D matrix, return all elements of the matrix in spiral order.
  • 03 Number of Islands: Given a 2D grid map of 1s (land) and 0s (water), count the number of islands.

Section 3: Linked List Interview Questions

  • 01 Implement a Stack Using an Array in Java: Implement a stack using an array.
  • 02 Add Two Numbers: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
  • 03 Reverse a Linked List: Reverse a singly linked list.

Section 4: Tree Interview Questions

  • 01 Inorder Traversal: Perform inorder traversal on a binary tree.
  • 02 Preorder Traversal: Perform inorder traversal on a binary tree.
  • 03 Postorder Traversal: Perform inorder traversal on a binary tree.
  • 04 Binary Tree Maximum Path Sum: Given a binary tree, find the maximum path sum.

Section 5: Graph Interview Questions

  • 01 Clone an Undirected Graph: Each node in the graph contains a label and a list of its neighbors.

Section 6: Sorting and Time Complexity

  • 01 Types of Time Complexity: Learn the types of time complexity in Big-O Notation in order of horrible to good.
  • 02 Bubble Sort Algorithm: Sort a list with bubble sort.
  • 03 Selection Sort Algorithm: Sort a list with selection sort.
  • 04 Insertion Sort Algorithm: Sort a list with insertion sort.
  • 05 Quick Sort Algorithm: Sort a list with Quick Sort.
  • 06 Merge Sort Algorithm: Sort a list with Merge Sort.
  • 07 Time Complexity of Different Sorting Algorithms

Section 7 Dynamic Programming Interview Questions

  • 01 Coin Change: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount.
  • 02 Edit Distance: Find the edit distance between two strings.
  • 03 Distinct Subsequences: Given a string S and a string T, count the number of distinct subsequences of T in S.
  • 04 Maximum Sum Subarray: Find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum

Section 8 Bit Manipulation Interview Questions

  • 01 Bitwise and Shift Operators: Manipulate bits and shift bits to change values.
  • 02 Single Number: Given an array of integers, every element appears twice except for one. Find that single one.
  • 03 Sum of Two Integers: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.
  • 04 Number of 1 Bits: Take an unsigned integer and return the number of ’1' bits it has (also known as the Hamming weight.)
  • 05 Reverse Bits: Reverse the bits of a given 32 bit unsigned integer.
  • 06 Bitwise AND of a Range: Given two non-negative long integers, a and b and given a <= b, find the bitwise AND of all integers from a and b.

Section 9 Combinations and Permutations Interview Questions

  • 01 Permutations: Print all permutations of a given string.
  • 02 Distinct Permutations of a String: Print all distinct permutations of a string that contains duplicates.
  • 03 Letter Combinations of a Phone Number: Given a digit string, return all possible letter combinations that the number could represent on a phone board.
  • 04 Factor Combination: Return all possible combinations of an integer n’s factors.

Section 10 Math Interview Questions

  • 01 Reverse Integer: Reverse the digits of an integer n.
  • 02 Palindrome Number: Determine whether an integer is a palindrome. Do this without extra space.
  • 03 Excel Sheet Column Numbe: Given a column title from an Excel sheet, return its corresponding column number.

WHO SHOULD ENROLL?

  • Anyone learning Java
  • You have a Java interview coming up and need to learn how to answer questions properly
  • You need to learn the most popular questions that you might be asked
  • You need to learn the top 10 most common subjects asked about and sample questions for each
  • You haven't used Java in a while and want to refresh your knowledge
 

A SCHOOL YOU CAN TRUST

  • Lifetime access that never expires
  • Project-based curriculum to superboost your portfolio
  • Graduation certificate for every course
  • Absolute beginner-friendly
  • New courses every month
  • Efficient lectures with step by step explanations
  • Relevant industry topics 8 years of award-winning course delivery
  • 700,000 students in 186 countries
  • Learn with free tools and affordable courses

Your Instructor


Alexandra Kropf
Alexandra Kropf

Alexandra Kropf is Mammoth Interactive's CLO and a software developer with extensive experience in full-stack web development, app development and game development. She has helped produce courses for Mammoth Interactive since 2016, including the Coding Interview series in Java, JavaScript, C++, C#, Python and Swift.

Mammoth Interactive is a leading online course provider in everything from learning to code to becoming a YouTube star. Mammoth Interactive courses have been featured on Harvard’s edX, Business Insider and more.

Over 12 years, Mammoth Interactive has built a global student community with 4 million courses sold. Mammoth Interactive has released over 350 courses and 3,500 hours of video content.

Founder and CEO John Bura has been programming since 1997 and teaching since 2002. John has created top-selling applications for iOS, Xbox and more. John also runs SaaS company Devonian Apps, building efficiency-minded software for technology workers like you.


Frequently Asked Questions


When does the course start and finish?
The course starts now and never ends! It is a completely self-paced online course - you decide when you start and when you finish.
How long do I have access to the course?
How does lifetime access sound? After enrolling, you have unlimited access to this course for as long as you like - across any and all devices you own.
What if I am unhappy with the course?
We would never want you to be unhappy! If you are unsatisfied with your purchase, contact us in the first 30 days and we will give you a full refund.
What is the format of the courses?
Average courses are 5-50 hours long, with our biggest (to date) being Hello Coding 2.0, at 250 hours of content! Most lessons are between 15 and 30 minutes long, and they’re all available online that you can watch at any time that’s convenient for you. The videos feature a live recording of your instructor's screen as they develop in realtime. With all source code and reference files included. So there will be absolutely no guesswork for you. And in case you ever get stuck, you can ask any questions and leave comments under each lecture.
Do I get course certificates?
Yes, a course certificate will be generated at the end of each course you complete! Along with projects, certificates are a way you can prove your work on LinkedIn.
Do I have to show up at a particular place or a particular time?
No, each course happens online, and you can take it from any place where you have an internet connection. You can view all lectures offline via the Teachable iOS app. All lectures are prerecorded so you can watch them at any time that works for you. Of course, you can also enjoy all the lectures on your phone and tablet.
How much time do I need in order to take each course?
You can spend as much or as little time as you want. If you enroll in Lifetime Access, you get lifetime access to all course materials. With Lifetime Access, there is no expiry. You aren't required to complete the course within a certain time period. You can follow the course at your own pace and always come back to the videos later when you want to revisit the material or work on improving certain skills.
What if I’m not good with technology?
The majority of Mammoth Interactive students are complete beginners. Even if you feel like you know nothing about technology, you won’t feel left out. All technical concepts are described in simple terms while avoiding unnecessary jargon. Each course starts from scratch and builds up your knowledge substantially in steps. Students from age 5 to 70 have successfully completed our courses. And just in case you get stuck, you can always ask any questions under each lecture, which will be promptly answered by one of my team members.
What if I'm an experienced developer?
Stack Overflow's yearly developer survey found that developers over age 50 start to make less than their younger counterparts. Don't become one of the people affected by skill stagnation. Enroll in our school to future-proof your career for life. If you're an experienced developer, you will still benefit from Mammoth Interactive courses. By starting from scratch with each course, you will revisit the fundamentals and undo bad coding habits. You'll also find it easier to pick up new languages, making you able to take more courses and broaden your skillset.

Requirements

  • Experience with object-oriented programming fundamentals. If you need experience, enrol in Introduction to Algorithms in Java first.
  • No IDE necessary. We'll run Java in the browser with Repl.

Course Curriculum


  Section 0 - Introduction
Available in days
days after you enroll

Get started now!