Second to smaller and larger in java
You will be given an array and you need to find the second largest and second smallest numbers and add them.
Note: the length of the array should not be less than 2.
Input Format -
you will be taking a number as an input from stdin which tells about the length of the array. On another line, array elements should be there with single space between them.
Output Format -
you need to print the addition of second largest and second smallest elements to the stdout.
Sample Test Case:
Sample Input:-7
48 77 7 11 49 99 78
Sample Output -
89
Note: the length of the array should not be less than 2.
Input Format -
you will be taking a number as an input from stdin which tells about the length of the array. On another line, array elements should be there with single space between them.
Output Format -
you need to print the addition of second largest and second smallest elements to the stdout.
Sample Test Case:
Sample Input:-7
48 77 7 11 49 99 78
Sample Output -
89
Comments
Post a Comment