← Nagarro questions

Count Pairs with Sum Closest to Target K

Filed under Nagarro

Given an integer K and two integer arrays A1 and A2, find the number of pairs (x, y) with x from A1 and y from A2 such that the absolute difference |(x + y) - K| is minimized.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Nagarro questions

Collected from public candidate posts and coding forums. Updated Nov 2026.