Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊInterview PrepModule 2 Β· Arrays, Strings, Two-Pointer Β· Recapβ€ΊπŸŽ― Review: Interview Prep module 2 recapscenario21 / 104
+80 XP
Task
Build the canonical Two Sum: `two_sum(nums, target)` returns the two indices summing to target (or `[-1, -1]` if no pair): - Use a dict `seen` mapping value β†’ index, so each scan is O(1) lookup. - Return indices in the order you found them (smaller index first). - No pair β†’ `[-1, -1]` (never raise). - Don't use the SAME index twice (e.g. for `[3], target=6`, do NOT return `[0,0]`). LeetCode #1 β€” the most-asked interview question on Earth.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…