array
array
php
• Write a Java program to replace every element with the next greatest element (from right side)
in an given array of integers.
• Write a Java program to separate 0s on left side and 1s on right side of an array of 0s and 1s in
random order.
• Write a Java program to separate even and odd numbers of an given array of integers. Put all
even numbers first, and then odd numbers.
• Write a Java program to sort an array of positive integers of an given array, in the sorted array
the value of the first element should be maximum, second value should be minimum value,
third should be second maximum, fourth second be second minimum and so on.
• Write a Java program to arrange the elements of an given array of integers where all positive
integers appear before all the negative integers.
• Write a Java program to cyclically rotate a given array clockwise by one
• Write a Java program to check whether there is a pair with a specified sum of a given sorted and
rotated array.
• Write a Java program to find all combination of four elements of an given array whose sum is
equal to a given value.
• Write a Java program to find smallest and second smallest elements of a given array.
• Write a Java program to get the majority element from an given array of integers containing
duplicates.
• Write a Java program to find all the unique triplets such that sum of all the three elements [x, y,
z (x ≤ y ≤ z)] equal to a specified number.
Sample array: [1, -2, 0, 5, -1, -4]
Target value: 2.
• Write a Java program to find the sum of the two elements of a given array which is equal to a
given integer.
Sample array: [1,2,4,5,6]
Target value: 6.
• Write a Java program to find the length of the longest consecutive elements sequence from a
given unsorted array of integers.
Sample array: [49, 1, 3, 200, 2, 4, 70, 5]
The longest consecutive elements sequence is [1, 2, 3, 4, 5], therefore the program will return
its length 5.
• Write a Java program to remove the duplicate elements of a given array and return the new
length of the array.
Sample array: [20, 20, 30, 40, 50, 50, 50]
After removing the duplicate elements the program should return 4 as the new length of the
array.
• Write a Java program to compute the average value of an array of integers except the largest
and smallest values.
• Write a Java program to find the number of even and odd integers in a given array of integers.
• Write a Java program to move all 0's to the end of an array. Maintain the relative order of the
other (non-zero) array elements.
• Write a Java program to sort a numeric array.
• Write a Java program to sum values of an array