From 9f7c85733289c8052e0af3ce5d00329fb475b262 Mon Sep 17 00:00:00 2001 From: wangyouming Date: Wed, 21 Aug 2024 11:49:24 +0800 Subject: [PATCH] SkipList `levelCount` update fix --- java/17_skiplist/SkipList.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/17_skiplist/SkipList.java b/java/17_skiplist/SkipList.java index 83acedf1..e4aa65b6 100644 --- a/java/17_skiplist/SkipList.java +++ b/java/17_skiplist/SkipList.java @@ -78,10 +78,9 @@ public void delete(int value) { } } - while (levelCount>1&&head.forwards[levelCount]==null){ + while (levelCount > 1 && head.forwards[levelCount - 1] == null) { levelCount--; } - } // 理论来讲,一级索引中元素个数应该占原始数据的 50%,二级索引中元素个数占 25%,三级索引12.5% ,一直到最顶层。