Day 3: Find the Second Largest Number in an Array
Submissions will no longer be placed on the leaderboard. You may still attempt this problem for practice.
You are given numbers. Store them in an array and find the second largest number.
Here are some useful videos related to arrays in JavaScript:
Also, W3 Schools has a nice, well summarized tutorial related to arrays in Javascript.
Input Format
The first line contains , the size of array .
The second line contains space separated elements of array .
Output Format
Output the value of the second largest number in array .
Sample Input
5
2 3 6 6 5
Sample Output
5
xxxxxxxxxx
17
1
2
3
function processData(myArray) {
4
5
}
6
7
// tail starts here
8
process.stdin.resume();
9
process.stdin.setEncoding("ascii");
10
_input = "";
11
process.stdin.on("data", function (input) {
12
_input += input;
13
});
14
15
process.stdin.on("end", function () {
16
processData(_input.split('\n')[1].split(' ').map(Number));
17
});