Java Array Intermediate Programs

Master fundamental Java concepts with these beginner-friendly programs

Second Largest Element

Find the second largest element in an array.

Check Array Sorted

Check if the array is sorted in ascending order.

Find Missing Number

Find the missing number in an array from 1 to n+1.

Remove Duplicates

Remove duplicate elements from an array.

Reverse Array In-Place

Reverse the elements of an array in-place.

Merge Two Sorted Arrays

Merge two sorted arrays into one sorted array.

Count Even and Odd Numbers

Count the number of even and odd elements in an array.

Find Pairs with Given Sum

Find all pairs in the array whose sum equals a given number.

Find Majority Element

Find the element that appears more than n/2 times in the array.

Rotate Array by K Positions

Rotate the array to the right by k steps.

Count Frequencies of Elements

Count frequency of each element in an array.

Find Kth Smallest Element

Find the k-th smallest element in an unsorted array.

Find Leaders in the Array

Find all leaders in the array (element greater than all to its right).

Find First Repeating Element

Find the first repeating element in an array.

Find Subarray with Given Sum

Find a continuous subarray that adds to a given sum.

Move All Zeros to End

Move all 0s to the end of array without changing the order of other elements.

Find Union and Intersection

Find the union and intersection of two arrays.

Maximum Product Subarray

Find the contiguous subarray within an array with the largest product.

Replace Every Element With Greatest on Right

Replace every element with the greatest element on its right.

Kadane’s Algorithm (Max Subarray Sum)

Find the maximum sum of a contiguous subarray.