Problem title
Difficulty
Avg time to solve

Two Squares
Moderate
30 mins
Hurdle Game
Easy
10 mins
Find the maximum element in the array after update operations.
Moderate
15 mins
Minimum Distinct Labels
Moderate
15 mins
Minimum time to cross all checkpoints
Hard
15 mins
Ninja and Infinite Size Array
Easy
15 mins
Special Numbers
Moderate
25 mins
All Prime Numbers less than or equal to N
Moderate
10 mins
MaxFreq_Element
Moderate
15 mins
Maximum Sum Path Of A Binary Tree.
Hard
25 mins

# Two Sum II - Input Array Is Sorted

Difficulty: MEDIUM

Problem Statement

#### Given an array ‘A’ of size ‘N’, sorted in non-decreasing order. Return the pair of two distinct indices whose value adds up to the given ‘target’. The given array is 0 indexed. So returned indices are in the range [0, N-1], both inclusive. If there are multiple answers, you can return any.

##### For example:
``````Suppose ‘N’ = 5, ‘A’ = [1,2,3,4,5], and target = 8
As target == A + A = 3 + 5 = 8.
Hence output will be 2 4.
``````

#### Input Format:

``````The first line of the input contains a single integer ‘T’ representing the no. of test cases.

The first line of each test case contains two space-separated integers, ‘N’ and ‘Target’, denoting the size of ‘A’ and the target sum value.

The second line of each test case contains ‘N’ space-separated integers representing the elements of ‘A’.
``````

#### Output Format:

``````For each test case, print two space-separated integers denoting the indices of elements of ‘A’, which add up to ‘target’.

Print a separate line for each test case.
``````
##### Note
``````You are not required to print anything; it has already been taken care of. Just implement the function and return the answer.
``````

#### Constraints -

``````1 ≤ T ≤ 1000
1 ≤ N ≤ 100000
-1000 ≤ A[i] ≤ 1000
ΣN ≤ 300000

Time limit: 1 Sec
``````
##### Sample Input 1 :
``````2
5 8
1 2 3 4 5
4 4
2 2 4 5
``````
##### Sample Output 1 :
``````2 4
0 1
``````
##### Explanation For Sample Input 1 :
``````For First Case - Same as explained in above example.

For the second case -

‘N’ = 4, ‘A’ = [2,2,4,5], and target = 4
As target == A + A = 2 + 2 = 4.
Hence output will be 0 1.
``````
##### Sample Input 2 :
``````3 8
1 7 8
2 10
1 9
``````
##### Sample Output 2 :
``````1 0
0 1
``````   Console