booleanvalidate(int[] s, int left, int right){ if (left >= right) returntrue; int cur = right; while(cur > left && s[cur - 1] > s[right]) cur--; for (int i = left; i < cur - 1; i++) { if (s[i] >= s[right]) returnfalse; } return validate(s, left, cur - 1) && validate(s, cur, right - 1); }