Implement binary search and solve three-sum problem