Given a sorted array of integers and a number n, find a pair of numbers in the array whose sum is n.
Start with a pair constituted of the first and last numbers of the sorted array. At each step, compute the sum of the current pair. If the sum is larger than our objective, take following element as the first of our pair. If it's smaller, take the previous element as the second element of the pair. If it's equal, then we have our solution.
###Implementation
Create a struct containing two pointers. It will be used as an input of the function (pointer to the first and the last element of the array), and an output (pointer to our two elements).
Just use array indices.
Use Data.Sequence
to handle the finite-size sorted list.
Google job interview.
Working at google: answers to google job interview programming problem mentioned in https://www.youtube.com/watch?v=XKu_SEDAykw