From 633aada3feb6fd740debcc6897c6e066ee7f8767 Mon Sep 17 00:00:00 2001 From: Stanton Date: Thu, 5 Jul 2018 15:46:43 -0700 Subject: [PATCH] =?UTF-8?q?Update=20the=20algorithm=20for=20=E4=BA=8C?= =?UTF-8?q?=E5=8F=89=E6=90=9C=E7=B4=A2=E6=A0=91=E7=9A=84=E5=90=8E=E5=BA=8F?= =?UTF-8?q?=E9=81=8D=E5=8E=86=E5=BA=8F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notes/剑指 offer 题解.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notes/剑指 offer 题解.md b/notes/剑指 offer 题解.md index c0c5412f..0dd2ea24 100644 --- a/notes/剑指 offer 题解.md +++ b/notes/剑指 offer 题解.md @@ -1532,10 +1532,10 @@ private boolean verify(int[] sequence, int first, int last) return true; int rootVal = sequence[last]; int cutIndex = first; - while (cutIndex < last && sequence[cutIndex] <= rootVal) + while (cutIndex < last && sequence[cutIndex] > rootVal) cutIndex++; for (int i = cutIndex + 1; i < last; i++) - if (sequence[i] < rootVal) + if (sequence[i] > rootVal) return false; return verify(sequence, first, cutIndex - 1) && verify(sequence, cutIndex, last - 1); }