Adobe Interview Question

Find 2nd largest number in an array of integers

Interview Answer

Anonymous

Sep 15, 2022

First need to sort out the array using inbuild function or write any sorting algorithm like Bubble, Quick or Merge, whatever algo seems more efficient then just set the index 2 to get the second largest. Below is a simple javascript solution getSecondLargest(arr, len) { return len b - a)[1]; }