56: Two Sum in a sorted array

Given an sorted array of integers and sum, return indices of numbers whose sum is equal to the given sum

Note: Each integer can be used only once and the input has exactly one solution

 

Example 1

Input: array = [2, 6, 9, 15], sum = 15

Output: [1, 2]

Explanation: array[1] + array[2] = 15

Example 2

Input: array = [1, 2, 2, 4, 5], sum = 4

Output: [1, 2]
Difficulty:Easy
Topic:Binary Search
Problem #:56