Lazy-Update Hashmap
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.
- 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
Susquehanna interview guideKnow what Susquehanna asks before you walk in.
8 coding · 1 system design · 26 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.