Hey everyone! I’m Mahdi Shamlou, and I’m starting a new series on classic LeetCode problems. Let’s kick it off with the very first one: Problem #1 — Two Sum.

This is an Easy difficulty problem, but it’s legendary — it’s often the very first question in coding interviews at big tech companies. Solving it optimally shows you understand one of the most powerful tools in programming: hash maps (dictionaries in Python). Problem Statement: Two Sum

Given an array of integers nums and an integer target, return the indices of the two numbers such that they add up to target.

You may assume that each input has exactly one solution, and you may not use the same element twice. You can return the answer in any order.

Examples:

Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Expl...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help