diff --git a/animation-simulation/栈和队列/leetcode402移掉K位数字.md b/animation-simulation/栈和队列/leetcode402移掉K位数字.md index 2ffe931..60e4b27 100644 --- a/animation-simulation/栈和队列/leetcode402移掉K位数字.md +++ b/animation-simulation/栈和队列/leetcode402移掉K位数字.md @@ -75,7 +75,7 @@ class Solution { } stack.push(i); } - while (k > 0) { + while (k > 0 && !stack.isEmpty()) { stack.pop(); k--; }