In this programming tutorial, we will read an unsorted array, sort it, and then will find the pair with the given sum.
We maintain a search space in the while loop with 'l' for left index and 'r' for right index. 'l' and 'r' will increment or decrements respectively depending on the sum of the pairs being tested inside the 'while' loop.
Given below is the source code for the algorithm:
We maintain a search space in the while loop with 'l' for left index and 'r' for right index. 'l' and 'r' will increment or decrements respectively depending on the sum of the pairs being tested inside the 'while' loop.
Given below is the source code for the algorithm:
No comments:
Post a Comment