Write a C program to find the second largest distinct element in an array. If the array size is less than 2 or does not have at least two distinct elements, print "N/A".
Example 1
Input:
5
10 20 5 30 15
Output:
20
Example 2
Input:
3
10 10 10
Output:
N/A
Constraints
1 <= n <= 100
Input Format
n, array logic
Output Format
Second largest or N/A
Sample Testcases
Submit runs every public testcase in this browser. Results and code never leave this device.
Sample #1
Public sample
Input
5
10 20 5 30 15
Output
20
Explanation
Max is 30, second is 20.
Sample #2
Public sample
Input
3
10 10 10
Output
N/A
Explanation
No distinct second largest.
Sample #3
Public sample
Input
5
10 20 10 20 5
Output
10
Explanation
Distinct values 5, 10, 20. Max 20, 2nd 10.
Sample #4
Public sample
Input
4
-10 -20 -5 -2
Output
-5
Explanation
Max -2, 2nd -5.
Sample #5
Public sample
Input
2
5 1
Output
1
Explanation
Just two elements.
Web terminal
C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.