Segment trees

Asked atGoogle
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+
  1. 01Define the aggregate operation
  2. 02Build interval nodes
  3. 03Answer with overlap cases
  4. 04Update one root-to-leaf path
  5. 05State tree bounds and alternatives

Reference answer

Then expect these follow-ups

  • Why must the operation be associative?

    Tests: correctness reasoning

  • When is a Fenwick tree a better choice?

    Tests: follow-up reasoning

Hiring now

Google has 52 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.
  • Small Business Field Sales Representative

    Austin, Texas

  • Program Manager PMO, Enterprise

    Remote

  • Vendor Performance Manager, Customer Support

    Remote

Or practice this question first

Next question