Rectangle Counting

  1. Please explain the use of two for loops to traverse and why did we stop at one previous element from the last.

  2. What is the difference between doin “It+1” and “next(it)”

hello @anindya-gupta

because the inner loop is always starting from one element next of outer loop. so to make sure that inner and outer loop stay valid we are stopping first loop at second last element.

it+1 we can do on linear stuctures like array or vector.
here set is implemented using tree which is not linear thats why we are using next function to get the next element

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

why we are doing ans/2 in video, i think we don"t have to do it