InterviewLegend

Lazy-Update Hashmap

Alex Chen30 min readUpdated

Susquehanna's software-engineering online assessment is a CodeSignal General Coding Assessment, and one problem shows up on it often enough to be worth drilling cold: a hashmap that supports bulk updates. You process a stream of operations, four kinds in all. Add key val adjusts one entry. AddToKey val shifts every key at once. AddToValue val shifts every value at once. get key reads one entry back. The catch is the constraint, up to 100,000 operations, so a solution that loops over the whole map on every AddToKey or AddToValue is quadratic and will not finish in time.

The whole problem turns on one idea. You never rewrite every entry when a bulk operation lands. You record the shift as a running total and fold it back in only at the moment someone reads or writes a specific key. Two integers, a key offset and a value offset, carry all of the "add to everything" work, and every operation collapses to O(1). This is a lighter version of Fancy Sequence (LeetCode 1622); once the multiply operation joins the party, it becomes exactly that problem, which is where the follow-up goes.

A note on scope. This is the software-engineer / quant-developer coding track, not the quant-trader track (which runs a probability and mental-math assessment instead). If your assessment is the CodeSignal GCA, roughly four questions in about 70 minutes at easy-to-medium difficulty, this is the right lesson. The OA rewards picking the right data structure and getting the state exactly right, not deep dynamic programming.
What's inside
  • 2 problems, worked step by step
  • about 30 min

Premium lessonSusquehanna interview guide

These took digging.

What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.

100 companies. Checked every month.

Unlock all 100 companies

$49 a year · less than $1 a week · Cancel anytime

Had your Susquehanna interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Susquehanna interview guide

Know what Susquehanna asks before you walk in.

8 coding · 1 system design · 26 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.