This guide is designed to help you strengthen
your Java programming skills.
With 50 thoughtfully selected problems, ranging
from easy to hard, you'll practice core Java
concepts, algorithms, and data structures.
Each problem includes a link to a CodeChef
challenge for hands-on practice.
www.learnbay.co
1Section 1 Easy-Level Questions
1 Number Mirror
Practice basic input/output handling.
Practice Problem
Difficulty: Easy
2 Turbo Sort
Sort a list of numbers quickly.
Practice Problem
Difficulty: Easy
www.learnbay.co
3 Life, the Universe, and Everything
Stop processing input upon encountering 42.
Practice Problem
Difficulty: Easy
4 Reverse The Number
Reverse the digits of an integer.
Practice Problem
Difficulty: Easy
5 Second Largest
Find the second largest number in a triplet.
Practice Problem
Difficulty: Easy
www.learnbay.co
6 Factorial
Compute the factorial of a number.
Practice Problem
Difficulty: Easy
7 Small Factorial
Calculate factorial for smaller values efficiently.
Practice Problem
Difficulty: Easy
8 Enormous Input Test
Handle large input efficiently.
Practice Problem
Difficulty: Easy
www.learnbay.co
9 Valid Triangles
Check if three angles form a valid triangle.
Practice Problem
Difficulty: Easy
10 GCD and LCM
Find the GCD and LCM of two numbers.
Practice Problem
Difficulty: Easy
www.learnbay.co
1Section 2 Medium-Level Questions
11 Chef and Operators
Compare two numbers using operators.
Practice Problem
Difficulty: Medium
12 Missing a Point
Find the missing coordinate in a set of rectangles.
Practice Problem
Difficulty: Medium
www.learnbay.co
13 The Lead Game
Determine the winner of a game based on
cumulative scores.
Practice Problem
Difficulty: Medium
14 Magical Candy Store
Distribute candies optimally.
Practice Problem
Difficulty: Medium
15 Carvans
Find the maximum number of cars moving at full speed.
Practice Problem
Difficulty: Medium
www.learnbay.co
16 Array Rotation
Rotate an array to the left or right by a
given number.
Practice Problem
Difficulty: Medium
17 Count Subarrays
Count the number of subarrays satisfying
specific conditions.
Practice Problem
Difficulty: Medium
18 Chef and Subarrays
Optimize subarray processing with prefix sums.
Practice Problem
Difficulty: Medium
www.learnbay.co
19 Chef and Strings
Calculate the difference between
consecutive strings.
Practice Problem
Difficulty: Medium
20 Substring XOR Queries
Find XOR values for specific substrings.
Practice Problem
Difficulty: Medium
21 Chef and Subarrays
Find the number of subarrays with a given sum.
Practice Problem
Difficulty: Medium
www.learnbay.co
22 Chef and Socks
Predict which sock Chef will draw first.
Practice Problem
Difficulty: Medium
23 String Reverse
Reverse a string while maintaining case sensitivity.
Practice Problem
Difficulty: Medium
24 Subarray XOR
Calculate XOR for a specific range of subarray.
Practice Problem
Difficulty: Medium
www.learnbay.co
25 Chef and the Division Game
Determine divisors of numbers in a given range.
Practice Problem
Difficulty: Medium
26 Chef and Time Travel
Simulate Chef's time-travel algorithm.
Practice Problem
Difficulty: Medium
27 Longest Increasing Subsequence
Find the length of the longest increasing
subsequence in an array.
Practice Problem
Difficulty: Medium
www.learnbay.co
28 Chef and Sorting
Sort an array using a custom comparison function.
Practice Problem
Difficulty: Medium
29 Pair Sum
Find pairs in an array that sum up to a target value.
Practice Problem
Difficulty: Medium
30 Prefix Sum Array
Calculate and use the prefix sum array efficiently.
Practice Problem
Difficulty: Medium
www.learnbay.co
1Section 3 Hard-Level Questions
31 Matrix Chain Multiplication
Optimize the multiplication of matrices.
Practice Problem
Difficulty: Hard
32 Chef and Swaps
Minimize the swaps required for array transformation.
Practice Problem
Difficulty: Hard
www.learnbay.co
33 Chef and Divisor Tree
Find the divisors of a number in a tree-like structure.
Practice Problem
Difficulty: Hard
34 Segment Tree Queries
Answer queries efficiently using segment trees.
Practice Problem
Difficulty: Hard
35 Maximum Subarray XOR
Find the maximum XOR of any subarray.
Practice Problem
Difficulty: Hard
www.learnbay.co
36 Longest Palindromic Subsequence
Find the longest palindromic subsequence in a string.
Practice Problem
Difficulty: Hard
37 Chef and Graph Queries
Process graph queries efficiently.
Practice Problem
Difficulty: Hard
38 Maximize Bitwise AND
Find the maximum bitwise AND of elements in an array.
Practice Problem
Difficulty: Hard
www.learnbay.co
39 Traveling Salesman Problem
Solve the classic TSP problem with dynamic
programming.
Practice Problem
Difficulty: Hard
40 Kth Smallest Number in Stream
Find the kth smallest number in a continuous stream.
Practice Problem
Difficulty: Hard
41 Matrix Path Minimum Cost
Find the minimum cost path in a matrix.
Practice Problem
Difficulty: Hard
www.learnbay.co
42 Partition Problem
Check if an array can be partitioned into
two subsets of equal sum.
Practice Problem
Difficulty: Hard
43 Chef and Spanning Tree
Find the minimum spanning tree of a graph.
Practice Problem
Difficulty: Hard
44 Chef and Graph Coloring
Determine the chromatic number of a graph.
Practice Problem
Difficulty: Hard
www.learnbay.co
45 Maximal Clique
Find the largest clique in a graph.
Practice Problem
Difficulty: Hard
46 Chef and Palindromic Substrings
Count all palindromic substrings in a string.
Practice Problem
Difficulty: Hard
47 Weighted Interval Scheduling
Find the maximum weight of non-overlapping intervals.
Practice Problem
Difficulty: Hard
www.learnbay.co
48 Chef and Longest Path
Find the longest path in a tree graph.
Practice Problem
Difficulty: Hard
49 Dynamic Programming -
Knapsack Problem
Solve the 0/1 Knapsack problem using DP.
Practice Problem
Difficulty: Hard
50 String Permutations
Generate all permutations of a string.
Practice Problem
Difficulty: Hard
www.learnbay.co
38 Valid Anagram
Problem: Determine if two strings are anagrams
of each other
PracticeLink
39 Group Anagrams
Problem: Group strings that are anagrams of each
other
PracticeLink
40 Minimum Window Substring
Problem: Find the minimum window substring in `s`
that contains all the characters of `t`
PracticeLink
www.learnbay.co