Back to Tracks
☕ Java Track•175 Questions Total

Java Zero to Hero Practice Roadmap

A structured practice roadmap. Solve foundational logic, array algorithms, data structures, recursion, dynamic programming, and system design problems.

Your Progress:0 / 175 Solved

Keep going! Master these to reach hero status.

1

Basic Programming(1–20)

Fundamental control flow, math, and number manipulation.

20 / 20 Questions Ready
#1

Print 'Hello World'

Active

Write a standard Java program that prints 'Hello, World!' to the console output.

#2

Swap two numbers without using a third variable

Active

Swap two integer variables `a` and `b` without introducing a temporary third variable.

#3

Check if a number is even or odd

Active

Given an integer `n`, determine if it is Even or Odd using arithmetic operators.

#4

Find the largest of three numbers

Active

Write a program to determine and print the largest of three integers `a`, `b`, and `c`.

#5

Check if a number is positive, negative, or zero

Active

Determine whether a given number is positive (> 0), negative (< 0), or zero (== 0).

#6

Calculate the factorial of a number

Active

Calculate n! (n factorial) for a non-negative integer n.

#7

Generate the Fibonacci series

Active

Generate the first N terms of the Fibonacci sequence starting from 0, 1.

#8

Reverse a number

Active

Given an integer n, reverse its digits (e.g. 1234 -> 4321).

#9

Check if a number is a palindrome

Active

Check whether a given integer reads the same backwards as forwards.

#10

Check if a number is prime

Active

Determine if a number n > 1 is a prime number (divisible only by 1 and itself).

#11

Print all prime numbers in a range

Active

Print all prime numbers between a given range [start, end].

#12

Find the GCD (HCF) of two numbers

Active

Find the Greatest Common Divisor (GCD) of two integers `a` and `b` using Euclidean algorithm.

#13

Find the LCM of two numbers

Active

Calculate the Least Common Multiple (LCM) of two numbers `a` and `b`.

#14

Count the digits in a number

Active

Count the total number of digits in an integer n.

#15

Find the sum of digits

Active

Calculate the sum of all digits of a given integer n.

#16

Check if a number is an Armstrong number

Active

Check if a number of k digits equals the sum of its digits each raised to the k-th power (e.g. 153 = 1^3 + 5^3 + 3^3).

#17

Check if a number is a perfect number

Active

Check if a number equals the sum of its proper positive divisors (excluding itself e.g. 6 = 1 + 2 + 3).

#18

Print multiplication tables

Active

Print the multiplication table for a given integer n up to 10.

#19

Generate a number pyramid

Active

Print a centered number pyramid pattern of height N.

#20

Print various star patterns

Active

Print a right-angled star triangle pattern of N rows.

2

Arrays(21–45)

Traversal, searching, sorting, and core 1D array operations.

25 / 25 Questions Ready
#21

Find the largest element in an array

Active

Find and return the maximum element present in an integer array.

#22

Find the smallest element in an array

Active

Find and return the minimum element present in an integer array.

#23

Find the second largest element in an array

Active

Find the second largest distinct element in an array in O(n) time.

#24

Find duplicate elements in an array

Active

Find all duplicate values present in an array.

#25

Remove duplicates from an array

Active

Remove duplicate values from a sorted array in-place or return a clean distinct array.

#26

Reverse an array

Active

Reverse an array of N integers in-place and print the reversed elements space-separated.

#27

Rotate an array left

Active

Rotate an array of N integers to the left by K positions.

#28

Rotate an array right

Active

Rotate an array of N integers to the right by K positions.

#29

Merge two sorted arrays

Active

Merge two sorted arrays into a single sorted sequence.

#30

Sort an array

Active

Sort an array of N integers in ascending order.

#31

Find missing number

Active

Given array of N-1 distinct integers in range 1 to N, find the missing integer.

#32

Find common elements between arrays

Active

Find common elements present in array A (size N) and array B (size M).

#33

Find intersection of arrays

Active

Compute the intersection of two integer arrays preserving duplicates.

#34

Find union of arrays

Active

Find the union of two integer arrays (distinct sorted elements).

#35

Move all zeros to the end

Active

Move all zeros to end while maintaining relative order of non-zero elements.

#36

Find maximum subarray sum (Kadane's Algorithm)

Active

Find the contiguous subarray with the largest sum using Kadane's algorithm.

#37

Find pair with a given sum

Active

Find a pair of numbers in array adding up to target sum S.

#38

Find triplet with a given sum

Active

Find three elements whose sum equals target sum S.

#39

Find equilibrium index

Active

Find index where sum of lower indices equals sum of higher indices.

#40

Find frequency of elements

Active

Count frequency of each distinct element and print as 'x: count' in ascending order.

#41

Count even and odd numbers

Active

Count how many even and odd integers are present in array.

#42

Find majority element

Active

Find element appearing strictly more than N/2 times or print -1.

#43

Rearrange positive and negative numbers

Active

Rearrange array so all positive numbers appear before negative numbers.

#44

Find leaders in an array

Active

An element is a leader if it is >= all elements to its right.

#45

Find the longest consecutive sequence

Active

Find length of the longest consecutive sequence in unsorted array.

3

2D Arrays(46–55)

Matrix creation, traversal, searching, rotation, transpose, spiral order, and more.

10 / 10 Questions Ready
#46

Create and print a 2D matrix

Active

Read a 2D matrix of size R×C from stdin and print it row by row, with elements separated by spaces.

#47

Find the sum of each row and column in a matrix

Active

Given a 2D matrix, compute and print the sum of each row and the sum of each column.

#48

Transpose a matrix

Active

Compute the transpose of a given N×N square matrix (swap rows with columns).

#49

Search for an element in a matrix

Active

Search for a target value in an R×C matrix and print its position, or 'Not found' if absent.

#50

Find the diagonal sum of a matrix

Active

Compute the sum of primary and secondary diagonals of an N×N matrix.

#51

Print a matrix in spiral order

Active

Print all elements of an R×C matrix in clockwise spiral order.

#52

Rotate a matrix 90 degrees clockwise

Active

Rotate an N×N square matrix 90 degrees clockwise in-place.

#53

Find the maximum element in each row

Active

For each row in an R×C matrix, find and print the maximum element.

#54

Check if a matrix is symmetric

Active

Check if given N×N matrix is symmetric (matrix[i][j] == matrix[j][i]).

#55

Multiply two matrices

Active

Multiply two matrices A (R×K) and B (K×C) and print product matrix.

4

Strings(56–80)

String manipulation, pattern matching, sliding window on text.

25 / 25 Questions Ready
#56

Reverse a string

Active

Reverse the given string.

#57

Check if a string is a palindrome

Active

Check if input string reads the same forwards and backwards.

#58

Count vowels and consonants

Active

Count vowels and consonants in string (alphabetic characters only).

#59

Count words

Active

Count whitespace-separated words in sentence.

#60

Remove whitespace

Active

Remove all whitespace characters from input string.

#61

Remove duplicate characters

Active

Remove duplicate characters keeping only first occurrence.

#62

Find duplicate characters

Active

Find characters that appear more than once in string.

#63

Check if two strings are anagrams

Active

Check if two strings are anagrams (contain same characters).

#64

Find the first non-repeated character

Active

Find first non-repeated character or print 'None'.

#65

Find the first repeated character

Active

Find first character that repeats or print 'None'.

#66

Find the longest word

Active

Find the longest word in a sentence.

#67

Count character frequency

Active

Count frequency of each character in alphabetical order as 'char: count'.

#68

Compress a string

Active

Run-length compression: 'aabcccccaaa' becomes 'a2b1c5a3'.

#69

Reverse words in a sentence

Active

Reverse the order of words in a sentence.

#70

Check if one string is a rotation of another

Active

Check if string B is a rotation of string A.

#71

Convert lowercase to uppercase

Active

Convert all lowercase characters to uppercase without built-in toUpperCase().

#72

Find all substrings

Active

Generate all non-empty substrings of string space-separated.

#73

Find the longest common prefix

Active

Find longest common prefix string among N strings.

#74

Validate parentheses

Active

Determine if parentheses '()', '[]', '{}' are properly closed.

#75

Remove special characters

Active

Remove non-alphanumeric characters from string.

#76

Find the longest palindrome substring

Active

Find longest palindromic substring in S.

#77

Check if a string contains only digits

Active

Check if string consists exclusively of digits (0-9).

#78

Find the most frequent character

Active

Find character with highest frequency in string.

#79

Replace spaces with %20

Active

URL-encode string by replacing spaces with '%20'.

#80

Check if two strings are isomorphic

Active

Check if characters in string s can be replaced to get string t.

5

Object-Oriented Programming(81–95)

Classes, encapsulation, inheritance, polymorphism, abstraction, interfaces, exception handling, and deep copy.

15 / 15 Questions Ready
#81

Class and Constructor

Active

Create a class Student with fields name and roll. Read name and roll, instantiate a Student, and print details.

#82

Encapsulation with Getters and Setters

Active

Create BankAccount with private balance. Support deposit(amount) and withdraw(amount) only if balance >= amount.

#83

Method Overloading

Active

Implement a Calculator with overloaded add methods for (int, int), (int, int, int), and (double, double).

#84

Single Inheritance

Active

Create Animal with method sound() and derived class Dog with method bark(). Call both methods.

#85

Method Overriding (Runtime Polymorphism)

Active

Base Shape has method draw(). Derived Circle and Square override draw(). Call draw() using a Shape reference.

#86

Using the super Keyword

Active

Person has constructor taking name. Employee extends Person, calls super(name), and adds id. Print employee details.

#87

Static Variables and Methods

Active

Maintain a static counter that increments every time an instance of Item is created. Instantiate N items and print count.

#88

Abstract Classes and Methods

Active

Abstract class Vehicle has abstract speed() and concrete fuel(). Car extends Vehicle. Print outputs of both.

#89

Interfaces and Implementation

Active

Define interface Playable with method play(). Guitar and Piano implement Playable. Call play() on selected instrument.

#90

Multiple Interfaces Implementation

Active

SmartPhone implements Camera (takePhoto) and MusicPlayer (playMusic). Call both methods.

#91

Interface Default and Static Methods

Active

Interface Logger has static info(msg) and default log(msg). Implement in ConsoleLogger and invoke both.

#92

Composition (HAS-A Relationship)

Active

Engine has horsepower. Car HAS-A Engine. Instantiate Car with an Engine and print car status.

#93

Exception Handling (Try-Catch-Finally)

Active

Read a and b. Compute a / b. Catch ArithmeticException if b == 0 and print error. Always print 'Execution completed' in finally.

#94

Custom Exception

Active

Define InvalidAgeException extends Exception. Throw it if age < 18. Catch and print 'InvalidAgeException: Underage'. Else print 'Eligible for voting'.

#95

Copy Constructor and Deep Copy

Active

Implement Point with copy constructor Point(Point other). Create p1, copy to p2, mutate p1.x += 10, print both points.

6

Linked List(96–110)

Singly/doubly linked lists, cycle detection, multi-pointer strategies.

15 / 15 Questions Ready
#96

Create a singly linked list

Active

Read N integers, create a singly linked list, and print elements space-separated.

#97

Reverse a linked list

Active

Reverse a singly linked list iteratively and print elements.

#98

Detect a loop in a linked list

Active

Detect if linked list contains a cycle using Floyd's algorithm.

#99

Find the middle node of a linked list

Active

Find middle node value using slow and fast pointers.

#100

Remove duplicates from a sorted linked list

Active

Delete duplicate nodes from a sorted linked list.

#101

Merge two sorted linked lists

Active

Merge two sorted linked lists into one sorted linked list.

#102

Delete a node without the head pointer

Active

Given access only to that node, delete it from linked list.

#103

Find the nth node from the end

Active

Find value of K-th node from end of linked list.

#104

Check if a linked list is a palindrome

Active

Determine if linked list values form a palindrome.

#105

Reverse in groups of K

Active

Reverse nodes of linked list K at a time.

#106

Find the intersection point of two linked lists

Active

Find value of node where two singly linked lists merge.

#107

Detect and remove a cycle

Active

Remove cycle from linked list if present.

#108

Flatten a linked list

Active

Flatten a multi-level linked list with next and child pointers.

#109

Sort a linked list

Active

Sort linked list in ascending order in O(N log N) using merge sort.

#110

Clone a linked list with random pointers

Active

Create a deep copy of a linked list with next and random pointers.

7

Stack & Queue(111–125)

LIFO & FIFO structures, expression evaluation, monotonic stacks.

15 / 15 Questions Ready
#111

Implement a stack using an array

Active

Simulate stack push and pop operations.

#112

Implement a stack using a linked list

Active

Simulate linked list backed stack push and pop.

#113

Implement a queue using an array

Active

Simulate queue enqueue and dequeue operations.

#114

Implement a queue using a linked list

Active

Simulate linked list backed FIFO queue.

#115

Implement a queue using two stacks

Active

Implement FIFO queue semantics using two LIFO stacks.

#116

Implement a stack using two queues

Active

Implement LIFO stack semantics using two queues.

#117

Reverse a stack

Active

Reverse a stack of N integers and print elements from top to bottom.

#118

Reverse a queue

Active

Reverse elements in a queue using a stack.

#119

Check balanced parentheses

Active

Check if string of parentheses is balanced.

#120

Next greater element

Active

For each element, find the first greater element to its right, or -1.

#121

Stock span problem

Active

Calculate span of stock prices (consecutive days price was <= today).

#122

Min Stack

Active

Design a stack that retrieves the minimum element in O(1) time.

#123

Circular queue

Active

Simulate circular buffer queue with fixed capacity K.

#124

Evaluate postfix expression

Active

Evaluate value of postfix (Reverse Polish Notation) arithmetic expression.

#125

Infix to postfix conversion

Active

Convert valid infix expression with single-letter operands to postfix.

8

Trees & BST(126–140)

Binary trees, traversals, BST properties, ancestor problems.

15 / 15 Questions Ready
#126

Create a binary tree

Active

Build binary tree from level order array and print root value.

#127

Inorder traversal

Active

Print inorder traversal (left, root, right) of binary tree.

#128

Preorder traversal

Active

Print preorder traversal (root, left, right) of binary tree.

#129

Postorder traversal

Active

Print postorder traversal (left, right, root) of binary tree.

#130

Level-order traversal

Active

Print binary tree nodes in breadth-first level order.

#131

Find tree height

Active

Calculate max depth (height) of binary tree.

#132

Count leaf nodes

Active

Count number of leaf nodes in a complete binary tree.

#133

Check if two trees are identical

Active

Check if two binary trees are structurally identical with same values.

#134

Check if a tree is balanced

Active

A balanced binary tree has depth difference of subtrees <= 1.

#135

Find the Lowest Common Ancestor (LCA)

Active

Find Lowest Common Ancestor (LCA) of nodes p and q in a BST.

#136

Validate a Binary Search Tree (BST)

Active

Validate if binary tree satisfies BST invariants.

#137

Find the kth smallest element in a BST

Active

Find K-th smallest element in a Binary Search Tree.

#138

Mirror a binary tree

Active

Convert binary tree into its mirror image.

#139

Diameter of a binary tree

Active

Find length of longest path between any two nodes in tree.

#140

Serialize and deserialize a binary tree

Active

Convert binary tree to string and back to identical tree.

9

Hashing(141–150)

HashMaps, HashSets, frequency counting, fast O(1) lookups.

10 / 10 Questions Ready
#141

Two Sum problem

Active

Find 0-based indices of two numbers that add up to target.

#142

Find duplicates using a HashSet

Active

Check if array contains any duplicate values.

#143

Count frequencies using a HashMap

Active

Count frequency of each element and print sorted.

#144

Group anagrams

Active

Group an array of strings into anagram clusters.

#145

Find the first unique element

Active

Find first non-repeating element in array or -1.

#146

Find the longest consecutive sequence

Active

Find length of longest consecutive elements sequence.

#147

Detect duplicate values

Active

Return true if any value appears at least twice in array.

#148

Find subarrays with sum K

Active

Count total contiguous subarrays whose sum equals K.

#149

Find common elements

Active

Find intersection of elements in arrays A and B.

#150

LRU Cache implementation

Active

Simulate Least Recently Used (LRU) Cache get and put operations.

10

Recursion & Backtracking(151–160)

Subsets, permutations, N-Queens, maze traversal.

10 / 10 Questions Ready
#151

Factorial using recursion

Active

Calculate N! using recursion.

#152

Fibonacci using recursion

Active

Compute N-th Fibonacci number recursively (0-indexed).

#153

Generate all subsets

Active

Generate all 2^N subsets of an integer array.

#154

Generate permutations

Active

Calculate total distinct permutations of array of N distinct integers.

#155

Solve the N-Queens problem

Active

Find number of distinct valid solutions to place N non-attacking queens on an N×N board.

#156

Solve Sudoku

Active

Check if a 9x9 Sudoku board state is valid.

#157

Rat in a Maze

Active

Check if path exists from top-left (0,0) to bottom-right (N-1,N-1) in maze.

#158

Word Search

Active

Determine if word exists in 2D character grid by adjacent cells.

#159

Tower of Hanoi

Active

Calculate minimum moves required to solve Tower of Hanoi with N disks (2^N - 1).

#160

Generate balanced parentheses

Active

Calculate total valid combinations of N pairs of balanced parentheses (Catalan number).

11

Dynamic Programming(161–170)

Memoization, tabulation, subproblem optimization.

10 / 10 Questions Ready
#161

Climbing stairs

Active

Count distinct ways to climb N steps taking 1 or 2 steps at a time.

#162

Coin change

Active

Find fewest number of coins needed to make up amount A.

#163

Knapsack (0/1)

Active

Find maximum value that can be put in a knapsack of capacity W.

#164

Longest Common Subsequence (LCS)

Active

Find length of longest common subsequence of two strings.

#165

Longest Increasing Subsequence (LIS)

Active

Find length of longest strictly increasing subsequence in array.

#166

Edit distance

Active

Find minimum operations (insert, delete, replace) to convert word1 to word2.

#167

House Robber

Active

Maximize robbery amount without robbing adjacent houses.

#168

Maximum Product Subarray

Active

Find contiguous subarray that has largest product.

#169

Minimum Path Sum

Active

Find path from top left to bottom right of R×C grid minimizing sum of numbers.

#170

Partition Equal Subset Sum

Active

Determine if array can be partitioned into two subsets with equal sum.

12

Advanced Problems(171–175)

System design basics, LRU caches, multithreading, system architectures.

5 / 5 Questions Ready
#171

Implement an LRU Cache

Active

Implement LRU Cache data structure supporting get and put in O(1).

#172

Design a Parking Lot system

Active

Design parking lot with parking spots for small, medium, and big cars.

#173

Design a Library Management System

Active

Manage book checkouts and returns tracking availability.

#174

Implement a URL Shortener

Active

Design Base62 URL shortener converting integer IDs to short URLs.

#175

Design a Multi-threaded Producer-Consumer system

Active

Simulate thread-safe bounded buffer producer and consumer.