As an optimization for step 4 (lookup table), you can even shave another log, since in those chunks you only have to query at the margins (either a prefix query or a suffix one).
@jeroenodb3 жыл бұрын
But what if you get handed a very small query in a block from position 2 to 0.5 log(n)-1? Then you don't have the answer stored in the lookup table and you cannot answer faster than walking from 2 to 0.5log(n)-1, which takes O(log(n)) time.
@mihailstoian72373 жыл бұрын
@@jeroenodb Right, I also figured that out some hours after having writed that :)
@maristotero33526 жыл бұрын
Thank you so much! It was uploaded 5 years ago but helped me with my struggles with LA very much!
@PinkuDebNath11 жыл бұрын
Nice video! But I feel so stupid :| I lost track after LCA.
@ipmankus7 жыл бұрын
Read on topcoder :) , this is an uneasy explanation for competitive programming