Wednesday, June 10, 2015

Haskell 99 Problem 40

Problem

Please find the problem here.

Solution:

Please see the solution as follow:

This problem is known as 2-sum problem. Given a sorted list of numbers find two of them that sums to a particular value. Leveraging the order we already have, we fix one value and binary search the another. For simplicity I reused the AVL tree I had.

No comments :

Post a Comment