int solution(int A[], int N) { if (N < 2) { return 0; } int max_moves = 0; int left = 0; int right = N - 1; int target_sum = 0; while (left < right) { int current_sum = A[left] + A[right]; if (current_sum == target_sum) { max_moves++; left += 2; right -= 2; } else if (current_sum < target_sum) { left++; } else { right--; } } return max_moves; }
2
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)