Two Sum

easy
1.Given an array of integers, return indices of the two numbers such that they add up to a specific target. 2.You may assume that each input would have exactly one solution, and you may not use the same element twice. 3.Your taks is to complete the function twoSum() to return the arraylist containing indices of two elements.

Input Format

1.First line contains 'N' denoting the size of the array. 2.Second line contains 'N' space separated elements. 3.Third line contains integer 'target'.

Output Format

Return arraylist of indices.

Constraints

2<=N<=1000

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
4
2 7 11 15
9
Output
[0, 1]
Previous
Top-k-frequency Words
Next
Uncommon Characters

Related Questions