Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 04 · DSA · DSA, in Hinglish · about 17 min to read

Play it as a journeyTutor comes with a plan

Foundations #04: Hashing (O(1) “yaad”)

Track: Foundations

Hashing — O(1) Yaad
Hashing, O(1) Yaad · Open board

Cloakroom token se lekar us chain tak jab do bags ek hi khaane mein gir jaate hain, aur wo teen patterns jo zyadatar interview sawaalon mein chal jaate hain.

Pehle ye jaan lo. Foundations #03: Arrays, Do-Pointer & Sliding Window ka array scan (ek-ek karke check karna) yehi lesson tez banata hai. Bas itna pata ho ki % (modulo) ek number ka baaki hissa deta hai, jaise 7 % 5 = 2.

Lesson 32 of 96 in DSA

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1968 - jis trick ka koi naam nahi tha
  • Cloakroom ka token, hash function ek number deta hai
  • Jab do cheezein ek hi bucket mein gir jaayein
  • Rack bhar jaaye toh
  • Jab koi jaan-boojh kar sabko ek hi bucket mein daale
  • Set ya Map, ek jaisa dikhta hai par kaam alag
  • Tum ab jaante ho
  • Do alag kaam, jinko log ek samajhte hain
  • “Sab ek step”, kitne, sach mein?
  • Load factor, naapa hua
  • Worst case O(n), bol mat, bana ke dikha
  • Set vs Map, chaar naapi hui wajahein
  • Pattern A, frequency count
  • Pattern B, “pehle dekha?” (Two Sum ki jaan)
  • Pattern C, group by key
  • THE TELL, hash kab?
  • Retrieval

Terms it explains: hash function, bucket, collision, O(1), load factor, table, 85.5%, 1.17, 276 / 276.

Lab

A hash map answers in one step, on average. What is the worst case, and when does it start to matter?

Choose Add up the letters, drag Keys per peg to the right, and watch the worst key number under What a lookup costs.

Open O(1) yaad

Review DSA