From 5472520edef040e55b0b91e8300516bdd9ca8325 Mon Sep 17 00:00:00 2001 From: jaredliw Date: Sat, 2 Oct 2021 21:28:11 +0800 Subject: [PATCH] 'while (k > 0) {' -> 'while (k > 0 && !stack.isEmpty()) {' (java.util.EmptyStackException) --- animation-simulation/栈和队列/leetcode402移掉K位数字.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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--; }