1class Solution {2public int findUnsortedSubarray(int[] nums) {3int[] numsClone = nums.clone();4Arrays.sort(nums);56int s = Integer.MAX_VALUE;7int e = Integer.MIN_VALUE;89for (int i = 0; i < nums.length; i++) {10if (numsClone[i] != nums[i]) {11s = Math.min(s, i);12e = Math.max(e, i);13}14}1516if (s == Integer.MAX_VALUE || e == Integer.MIN_VALUE) {17return 0;18}1920return e - s + 1;21}22}