跳表删除元素更新levelCount异常
Author: wyc192273Created Apr 1, 2020Updated Apr 26, 2022
由于老师的代码,在levelCount-1处是有值的,如果如老师代码所写
while (levelCount>1&&head.forwards[levelCount]==null){ levelCount--; }
则,跳表中node的maxLevel会与外层的levelCount不一致
正确代码应该是:
while (levelCount>1&&head.forwards[levelCount-1]==null){ levelCount--; }
Source: wangzheng0822/algo