Última actividad 1729868562

Revisión 19666b8599600ea7c8ca231385b7d954f2aff5f2

q3.cpp Sin formato
1int minMoves(vector<int>arr, int n, int k) {
2
3 sort(arr.begin(), arr.end());
4
5 int i = 0, j = n - 1;
6 int moves = 0;
7
8 while (i <= j) {
9
10 if (arr[i] + arr[j] <= k) {
11 i++;
12 }
13
14 j--;
15
16 moves++;
17 }
18
19 return moves;
20}