Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (Data Structures & Algorithms) expand_more
Complexity & Foundations
Arrays & Strings
Linked Lists
Stacks & Queues
Hashing
Trees & Heaps
Graphs
Sorting Searching & DP

Two sum

Learn Two sum in Data Structures & Algorithms with a focused explanation, a topic-specific example, edge guidance, and a mastery check.

12 min read • Intermediate
data-structures-algorithms-043.py
python
nums=[2,7,11,15];target=9;seen={}
for i,x in enumerate(nums):
    if target-x in seen: print(seen[target-x],i);break
    seen[x]=i
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content

Lesson quizzes