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.
Divisible Sum Pairs
Divisible Sum Pairs
Sort by
recency
|
2443 Discussions
|
Please Login in order to post a comment
Perl:
Hi here is my Python solution. I can take any suggestions .
Here is my c++ solution, you can whatch the explanation here: https://youtu.be/aDv1iUSgnd8
Solution 1 : O(n^2)
Solution 2 : O(n)
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)