Error in the codes

THIS IS THE ERROR COMING IN RECENT CODES:-

runguard: warning: timelimit exceeded (wall time): aborting command
runguard: warning: command terminated with signal 15

@Tung_H share your code using cb ide so that i can take a look

#include #include <bits/stdc++.h> using namespace std; void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp; *yp = temp; } void selectionSort(int arr[], int n) { int i, j, min_idx; for (i = 0; i < n-1; i++) { min_idx = i; for (j = i+1; j < n; j++) if (arr[j] < arr[min_idx]) min_idx = j; swap(&arr[min_idx], &arr[i]); } } int main() { int n ; cin>> n; int arr[n]; for(int k=0; k<n ; k++){ cin>> arr[k]; } int f; cin>>f; selectionSort(arr,n); int t,v; t=0 ; v = sizeof(arr)/sizeof(t)-1; while(t<v){ if (arr[t]+arr[v] < f){ t++; } else if(arr[t]+arr[v] >f){ v–; } else if(arr[t]+arr[v]==f){ cout << arr[t]<<" and "<< arr[v]; } } return 0; }

@Tung_H your logic seems correct (2 pointer ) but implemented wrong
check this corrected one

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.