Segment Tree for Python

I wanted a template or an example of how to do segment tree in python. If someone can help me with this?

See this post. Similar query was asked already.

I have seen this earlier the code written in python is not clear and not understandable. Can you provide me with its explanation?

OK.
If you just want to know how to implement seg tree in python then you can see this for normal implementation (recursive) which is commonly followed.

The implementation in the above post uses iterative approach and you can read this to understand it.

1 Like