Program to find second largest number from set of array

AnswerBot
1y

Program to find second largest number from set of array

  • Sort the array in descending order

  • Return the second element of the sorted array

Abhishek Upadhyay
7mo
Explanation: The largest element of the array is 35 and the second largest element is 34 Input: arr[] = {10, 5, 10} Output: The second largest element is 5. Explanation: The largest element of the arr...read more
Mohammad Rashid
1y
public class Tester { public static int getSecondLargest(int[] a) { int temp; //sort the array for (int i = 0; i < a.length; i++) { for (int j = i + 1; j < a.length; j++) { if (a[i] > a[j]) { temp = a...read more
Add answer anonymously...
Hexaware Technologies Graduate Engineer Trainee (Get) Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter