How to use segment tree?
Build tree and query
You can read this aritical to learn some basic operations of segment tree.
Update and "Lazy Tag"
"Lazy Tag" is the most important part in updation. This method can reduce the time complexity to $$$O(\log(n))$$$ for each updation. It's obvious that we can't update the whole tree, or the time complexity will be $$$O(n)$$$ like build tree. To reduce the time complexity, if