JavaMediumArrays15 min
Second largest number in an array
Find the second largest distinct value in {12, 45, 45, 3, 78, 9}.
Example
Input
—
Output
—
Hints (1)
- Single pass with two variables, or distinct().sorted().skip(1) with Streams.
Find the second largest distinct value in {12, 45, 45, 3, 78, 9}.
Input
—
Output
—
Checking runner availability…