Found 2616 Articles for Java

How to Find the Largest Palindrome in an Array in Java?

Mr. Satyabrata
Updated on 05-Jan-2023 14:27:34

2K+ Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to find the largest palindrome in an array. A number is said to be a palindrome number if after reversing the same number it is equal to the original number. Let’s explore the article to see how it can be done by using Java programming language. To Show You Some Instances Instance-1 Suppose the original array is {857, 232, 1996991, 54545} After finding the largest palindrome of an array the result will be ... Read More

Find Count of Positive, Negative and Zero Elements in an Array in Java

Mr. Satyabrata
Updated on 05-Jan-2023 14:25:01

361 Views

In Java, Array is a non-primitive data type which stores values of similar data type. As per the problem statement we have to find the frequency of each element i.e how many times each element is occurring in an array. Let’s see how we can do it by using the Java programming language. To Show You Some Instances Instance-1 Suppose the original array is {21, 10, 26, 21, 10, 33, 33, 20, 10, 21} After finding the frequency of each element of an array the result will be − Element | Frequency ------------------------ 21 | 3 10 | 3 ... Read More

Find the Equilibrium Index of an array in Java?

Mr. Satyabrata
Updated on 05-Jan-2023 14:22:04

1K+ Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to find an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes and hence that is called the equilibrium index of an array. In this article, you will see how to get the equilibrium index of an array by using Java programming language. Let’s explore. To Show You Some Instances Instance-1 Suppose the original array is {-4, 6, 2, 1, -7, 5, 3 ... Read More

How to Find a Cumulative Sum Array in Java?

Mr. Satyabrata
Updated on 05-Jan-2023 14:20:18

3K+ Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data types. As per the problem statement we have to find a cumulative sum array which means array elements will be updated with the sum of the current element and all previous elements. To find the cumulative sum, the array must contain all numeric values. In this article, you will see how to find the cumulative sum of an array by using Java programming language. Let’s explore. To Show You Some Instances Instance-1 Suppose the original array is {2, 9, 3, 5, 1, ... Read More

How to find all leaders in an array in Java?

Mr. Satyabrata
Updated on 11-Jan-2023 11:30:25

3K+ Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to find leaders in an array. An element is a leader if it is greater than all the elements to its right side. Let’s start! To Show You Some Instances Instance-1 Suppose the original array is {16, 17, 4, 3, 11, 14, 23, 2, 6, 10}. After finding leaders in an array the result will be − 23 10 Instance-2 Suppose the original array is {16, 17, 4, 3, 5, 6, 9, 1, ... Read More

How to Check if the Given Arrays are Disjoint in Java?

Mr. Satyabrata
Updated on 05-Jan-2023 14:07:53

459 Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to check if the given arrays are disjoint. An array is said to be disjoint if two arrays have no element in common i.e. elements in the first array are not equal to elements in the second array. Let’s explore the article to see how it can be done by using Java programming language. To Show You Some Instances Instance-1 Suppose the original two arrays are {13, 44, 11, 19, 3} and {7, 12, ... Read More

How to Check if an Array is Empty or Not in Java

Mr. Satyabrata
Updated on 05-Jan-2023 13:45:12

13K+ Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to check if an array is empty or not. An array is said to be an empty array, if the array has zero element or no element in it. Let’s explore the article to see how it can be done by using Java programming language. To Show You Some Instances Instance-1 Suppose the original array is {1, 3}. After checking if it is empty or not the result will be − Array is ... Read More

Get the Triplets in an Array Whose Sum is Equal to a Specific Number in Java

Mr. Satyabrata
Updated on 19-Jan-2023 12:05:08

385 Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to get all the triplets in the array whose sum is equal to a specific number. Here triplets refer to any three elements of the array which meet a specific condition. Note − The array must be an integer array. Let’s explore the article to see how it can be done by using Java programming language. To Show You Some Instances Instance-1 Suppose the original array is {3, 4, 25, 6, 13, 9}. ... Read More

Find difference between first and second largest array element in Java

Mr. Satyabrata
Updated on 05-Jan-2023 12:42:16

2K+ Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to find the difference between the first largest and second largest number present in an array. Note − The array must be an integer array. Let’s explore the article to see how it can be done by using Java programming language. To Show You Some Instances Instance-1 Suppose the original array is {22, 45, 1, 10, 52, 27} After performing the operation, the result will be − The second largest element of an ... Read More

Find sum of two array elements index wise in Java

Mr. Satyabrata
Updated on 05-Jan-2023 12:39:23

17K+ Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. As per the problem statement we have to find the sum of two different arrays with respect to index and store it into a third array. Suppose a1[] is first array, a2[] is second array and a3[] is third array, then sum of a1[] and a2[] should be stored in a3[] i.e. a1[0] + a2[0] = a3[0] a1[1] + a2[1] = a3[1] a1[2] + a2[2] = a3[2] and so on. Let’s start! Note − Two array lengths must be the ... Read More

Advertisements