We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 10 Days of Javascript
  4. Day 3: Arrays

Day 3: Arrays

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics
  1. Prepare
  2. Tutorials
  3. 10 Days of Javascript
  4. Day 3: Arrays
Exit Full Screen View
  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial
  • Topics

Objective

In this challenge, we learn about Arrays. Check out the attached tutorial for more details.

Function Description

Complete the getSecondLargest function in the editor below.

getSecondLargest has the following parameters:

  • int nums[n]: an array of integers

Returns

  • int: the second largest number in

Input Format

The first line contains an integer, , the size of the array.
The second line contains space-separated numbers that describe the elements in .

Constraints

  • , where is the number at index .
  • The numbers in may not be distinct.

Sample Input 0

5
2 3 6 6 5

Sample Output 0

5

Explanation 0

Given the array , we see that the largest value in the array is and the second largest value is . Thus, we return as our answer.

  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy