I recently read about segment trees and their implementation but was unable to decide what values should I put on tree’s node to get the desired answer. Like I was solving SPOJ question GSS1, and finally did it with the help of articles available related to this question, where people store four values on a node to get an answer, but I didn’t understand how can I approach for solving these type of questions.

Maybe a little bit explanation of a question related to segment tree could help me to understand better.

EDIT: If someone can provide links to the problem related to segment trees in increasing order of difficulty, that would be a great help.