Java Program to Find the Minimum Distance between Array Elements

This is the Java Program to Find the Minimum Distance between Array Elements. Problem Description Given an array of n elements, and two integers say x and y, present in the array, find out the minimum distance between x and y in the array, that is the number of elements between x and y, including … Read more

advertisement

Java Program to Print Next Greater Element in Array

This is the Java Program to Print the Next Greatest Element in the Array in Order, Elements with no Greater Elements will have -1 Printed Next to them. Problem Description Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element … Read more

advertisement

Java Program to Find Local Maxima in an Array

This is the Java Program to Find Local Maximas 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 maxima if it greater than the element after it, and the element before it. For the elements at the … Read more

advertisement

Java Program to Print Odd Elements at Odd Index

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

advertisement

Java Program to Check if an Array is Increasing

This is the Java Program to Check if an Array is Strictly Increasing. Problem Description Given an array of integers check whether it is strictly increasing or not. A strictly increasing array is an array whose each element is greater than it’s preceding element. Example: Array = [1, 2, 3, 4, 5] Output: Array is … Read more

advertisement

Java Program to Find Missing Numbers in Array

This is a Java Program to Identify Missing Numbers in a Given Array. We made a method as getMissingNo in which we pass the array and length of the array as arguments and using this method we calculate the missing number and hence we get the desired output. Here is the source code of the … Read more

advertisement

Java Program to Segregate 0s and 1s in an Array

This is a Java Program to Segregate 0s on Left Side & 1s on Right Side of the Array. Here is a function to segregate all 0s on left and all 1s on right as segregate0and1. We define an array and pass this array along with its length to the function and segregate 0s and … Read more

advertisement

Java Program to Find Largest Element in an Array

This is a Java Program to Find the Largest Number in an Array. Enter the elements of array as input. By comparing elements of array with each other we get the largest number of the array. Here is the source code of the Java Program to Find the Largest Number in an Array. The Java … Read more

advertisement

Java Program to Find the Number of Elements in an Array

This is a Java Program to Find the Number of Elements in an Array. An array consisting of any number of elements is given. Now we take a variable and each time we encounter the next element of array it gets incremented. Hence we get the variable value as length of array. Also we can … Read more

advertisement

Java Program to Print All Non Repeated Elements in an Array

This is the Java Program to Find the Elements that do Not have Duplicates. Problem Description Given an array, print all the elements whose frequency is one, that is they do not have duplicates. Example: Array = [-1, -2, 3, 3, -2] Output = -1 Problem Solution Traverse through the array and find the frequency … 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.