Mistake in the Code of Sparse Table

Sir, There is a bit mistake in the code of the Sparse table.
When we are writing the init() function .
There we should resize the mat[i] by the value m+1, not by m

for(int i=0;i<n;i++) mat[i].resize(m+1);

Yes your approach should work.

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.