You are viewing a single comment's thread. Return to all comments →
function getSecondLargest(nums) { let first = -Infinity, second = -Infinity; for (let i = 0; i < nums.length; i++) { if (nums[i] > first) { second = first; first = nums[i]; } else if (nums[i] > second && nums[i] < first) { second = nums[i]; } } return second; }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 3: Arrays
You are viewing a single comment's thread. Return to all comments →