We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
C# Solution:
Explanation: we sort the array, and after the array is in a non descending order, we apply the two pointer method, "i" points to the current number and "j" starts from the end and works its way backwards until the number
"ar[i] + ar[j] < k" (after that there is no reason to continue, because none of the pairs will be divisible by k)
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →
C# Solution: Explanation: we sort the array, and after the array is in a non descending order, we apply the two pointer method, "i" points to the current number and "j" starts from the end and works its way backwards until the number "ar[i] + ar[j] < k" (after that there is no reason to continue, because none of the pairs will be divisible by k)