# Help me in solving LARGESECOND problem

### My issue

Why was the time limit exceeded?

### My code

``````#include <stdio.h>

void arrange(int arr[], int n){
for(int i = 0; i < n-1; ++i){
for(int j = 0; j < n-1; ++j){
if(arr[j] > arr[j+1]){
int hold = arr[j];
arr[j] = arr[j+1];
arr[j+1] = hold;
}
else{
continue;
}
}
}
}

int second_max(int a[],int  size){
int secondMax = 0;
for(int i = 0; i < size-1; ++i){
if(a[i] < a[size-1]){
secondMax = a[i];
}
}
return secondMax;
}

int main(void) {
int t;
scanf("%d", &t);
for(int i = 0; i < t; ++i){
int size;
scanf("%d", &size);
int arr[size];
for(int j = 0; j < size; ++j){
scanf("%d", &arr[j]);
}
arrange(arr, size);
int secondmax = second_max(arr, size);
printf("%d\n", secondmax+arr[size-1]);
}
return 0;
}

``````

Learning course: Arrays using C
Problem Link: CodeChef: Practical coding for everyone

@ayushmaan1104
due to O(n^2) complexity of your arrange function .
It will give u tle.
because according to the constraints
N it upto 10^5 which canâ€™t support O(n^2) complexity.