I saw this coding question on an online coding competition but I couldn't find the most optimal solution.
Here is the question:
"You are given an array A of N integers and Q queries.Each query is of the following type :
1 pos val: Update the element at index pos to val
2 pos : Find the smallest index i less than or equal to pos such that all elements between i and pos are same."
I somehow believe that we can use segment tree but I could not figure out what each index of the segment tree will represent.