How to solve this range update and point query question?

There are 2 types of queries.

1. Update values from l to r to v.

2. Retrieve the value at index k.

For queries of type 2 , I need to output the values.

1 \le Queries \le 10^5

How to solve this problem efficiently?

We can keep a segtree and lazily store the updates in the nodes , we are only interested at the last update made on the current node , so when we get updates we find the ranges which lie completely inside the update range and update the value of the latest update there and for a query we go from the root to the leaf node keeping track of the latest update happened on any node in this path. the answer is the latest update.