diff --git a/notes/剑指 offer 题解.md b/notes/剑指 offer 题解.md index c0c5412f..5dd25159 100644 --- a/notes/剑指 offer 题解.md +++ b/notes/剑指 offer 题解.md @@ -411,6 +411,9 @@ Stack in = new Stack(); Stack out = new Stack(); public void push(int node) { + if (in.isEmpty()) + while (!out.isEmpty()) + in.push(out.pop()); in.push(node); }