← All questions
MediumCoding
Sum Root to Leaf Numbers
Asked at
BitGo
Meta
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Carry the numeric prefix from root to current node.
- 02Extend it as current times ten plus node value.
- 03At a leaf, return the complete number.
- 04Sum left and right recursive results, handling null as zero.
Reference answer
Then expect these follow-ups
How would you collect the actual path strings?
Tests: path state
What changes for base b digits?
Tests: generalization
Hiring now
BitGo has 44 open roles right now
landed applies to roles like these for you, on each company’s own site, with answers written for the role.
Get 5x interviews10 free auto-applies. No card.
Senior Software Engineer - Mobile Backend
Toronto, Ontario, Canada
Backend Engineer E3 - India
India
Backend Engineer E3 - Ecosystem
India
Next question