For the best experience, increase the window size or view on a laptop or desktop device
Title | ||
|---|---|---|
Loading... | ||
For the best experience, increase the window size or view on a laptop or desktop device
Title | ||
|---|---|---|
Loading... | ||
Given an array of positive integers arr[] of size n, the task is to find the second largest distinct element in the array.
Note: If the second largest element does not exist, return -1.
Examples:
Output: 34
Explanation: The largest element of the array is 35 and the second largest element is 34.
Output: 5
Explanation: The largest element of the array is 10 and the second largest element is 5.
Input: arr[] = [10, 10, 10]
Output: -1
Explanation: The largest element of the array is 10 there is no second largest element.
Given an array of positive integers arr[] of size n, the task is to find the second largest distinct element in the array.
Note: If the second largest element does not exist, return -1.
Examples:
Output: 34
Explanation: The largest element of the array is 35 and the second largest element is 34.
Output: 5
Explanation: The largest element of the array is 10 and the second largest element is 5.
Input: arr[] = [10, 10, 10]
Output: -1
Explanation: The largest element of the array is 10 there is no second largest element.
Output