Java Program to Print the Longest Decreasing Subarray

This is the Java Program to Print the Longest Sub-Array that is decreasing. Problem Description Given an array of integers, find the longest contiguous subarray whose elements are decreasing, that is, the elements following the preceding elements in the subarray must be smaller than them. Example: Array = [5, 6, 3, 0, 7, 8, 9, … Read more

advertisement

Java Program to Find a Pair of Elements with the Given Difference

This is the Java Program to Print Pairs of Elements that have the Given Difference. Problem Description Given an array of n integers and a value, say m. Find out the pairs of elements from the array, whose difference is value m. Example: Array = [ 1, 2, 4, 5, 8, 10, 11] m = … Read more

advertisement

Java Program to Find Two Elements whose Sum is Equal to a Given Number

This is the Java Program to Find Two Elements whose Sum is Equal to a Given Number. Problem Description Given an array of n integers and a value, say m. Find out the pairs of elements from the array, whose sum values m. Example: Array = [ 1, 2, 4, 5, 8, 10, 11] m … Read more

advertisement

Java Program to Merge Two Arrays

This is the Java Program to Merge Two Arrays in Order. Problem Description Given two arrays of integers, merge them into a single sorted array in order. Example: Array1: [1,2,3,4,5] Array2: [2,3,6,7,8] Output: Array = [1,2,2,3,3,4,5,6,7,8] Problem Solution Create a new array of size equal to the sum of the sizes of the two arrays. … Read more

advertisement

Java Program to Print All the Leaders in an Array

This is the Java program to print all the leaders in an array. Problem Description Given an array of integers, find and print all the leaders of the array. A leader is defined as an element of the array which is greater than all the elements following it. The rightmost element is always a leader. … Read more

advertisement

Java Program to Split the Array and Add First Part to the End

This is the Java Program to Split an Array and Concatenate First Part to the End. Problem Description Given an array of integers, and a value n, denoting the number of parts in which array is to be splitted. Concatenate the first part of the array to the end. Example: Array1: [1,2,3,4,5] n = 3 … Read more

advertisement

Java Program to Find the Missing Element in an Integer Array

This is the Java Program to Find the Missing Element in an Integer Array. Problem Description Given an array of n-1 integers having no duplicates, and containing the integers in the range 1 to n. Find out the missing integer. Example: Array = [ 1, 2, 4, 5] Output : Missing integer = 3 Problem … Read more

advertisement

Java Program to Rotate an Array by n Elements

This is the Java Program to Rotate an Array by n Elements. Problem Description Given an array of integers, circularly rotate the elements of the array, by a given value, say n. Example: int array[] = {1,2,3,4,5} n = 3 output = {3,4,5,1,2} Problem Solution The idea is to use two loops. The outer loop … Read more

advertisement

Java Program to Find Local Minima in an Array

This is the Java Program to Find Local Minimas in an Array. Problem Description Given an array of integers, find out the local maxima present in the array. An element in an array is a local minima if it less than the element after it, and the element before it. For the elements at the … Read more

advertisement

Java Program to Print Even Elements at Even Index

This is the Java Program to Print Even Elements at Even Index Number. Problem Description Given an array of integers, print the even numbers present at even index numbers. Example: Array = [2,1,4,4,5,7] Output = 2 4 Problem Solution Iterate through the array, and check whether the current index is even or odd if it … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.