This is one of the basic interview question about algorithm about finding the two numbers from array such that there sum is equal to K.
In this post, we’ll look into different approaches for finding all the pair of integer such that there sum is equal to K.
Approach 1 Brute-Force
In this approach, for each input element check whether there is any element exist whose sum is K. This can be solved with just two loops.
Time Complexity : O(n^2) for nested loops, Space Complexity : O(1)