Write a function to find the second largest element in an array {12, 35, 1, 10, 34, 1}.
MediumProblem Statement
Write a function to find the second largest element in an array {12, 35, 1, 10, 34, 1}.
Sample Input
12 35 1 10 34 1
Sample Output
Second largest element: 34
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <stdio.h>
int secondLargest(int arr[], int n) {
// Your code here
}
int main() {
int arr[] = {12, 35, 1, 10, 34, 1};
printf("Second largest element: %d\n", secondLargest(arr, 6));
return 0;
}
Input
12 35 1 10 34 1
Expected Output
Second largest element: 34