๐ New Course:
AWS for Engineers
is now live! ย ยทย Use code
LAUNCH50
for 50% off Pro
Engineer
Tutorial
Learn
Blogs
Playground
Pricing
Search
โK
Login
Get Started
Python
Run
Reset
Copy
Stdin
Press
Ctrl+Enter
to run
main.py
# Write your Python code here def two_sum(nums, target): seen = {} for i, num in enumerate(nums): complement = target - num if complement in seen: return [seen[complement], i] seen[num] = i return [] # Test print(two_sum([2, 7, 11, 15], 9)) # [0, 1] print(two_sum([3, 2, 4], 6)) # [1, 2]
Output
Click "Run" to execute your code...