DEV Community

Discussion on: Algorithms in JavaScript with visual examples.

Collapse
 
swastikyadav profile image
Swastik Yadav • Edited

LPS value is actually correct. It is [0, 0, 0, 1, 2, 0]

I had a small typo in LPS algorithm. I added "i" instead of "1".

Thanks for pointing.

Collapse
 
sanzhardanybayev profile image
Sanzhar Danybayev

Yeah, that all because of the type. It changed the value and it also causes infinite loop.
Nevertheless that was a pleasure to read your article!