-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWeek_2
More file actions
22 lines (14 loc) · 993 Bytes
/
Week_2
File metadata and controls
22 lines (14 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Hey Coder! Ready for a fun challenge? 🌟
Imagine you have a list of numbers. Your mission, should you choose to accept it, is to find two numbers in that list that add up to a specific target number. But here’s the catch: you can’t use the same number twice! Once you’ve found them, just return the indices of those two numbers.
Example Adventures:
1. Input: `nums = [2, 7, 11, 15]`, `target = 9`
Output: `[0, 1]`
Explanation: Since `nums[0] + nums[1] = 2 + 7 = 9`, we return `[0, 1]`.
2. Input: `nums = [3, 2, 4]`, `target = 6`
Output: `[1, 2]`
Explanation: `nums[1] + nums[2] = 2 + 4 = 6`, so the result is `[1, 2]`.
3. Input: `nums = [3, 3]`, `target = 6`
Output: `[0, 1]`
Explanation: `nums[0] + nums[1] = 3 + 3 = 6`, so the answer is `[0, 1]`.
🎯 Your Goal: Write a function that takes in the list of numbers and the target value, then returns the indices of the two numbers that hit the target.
Ready to give it a shot? Happy coding! 🚀