@@ -0,0 +1,663 @@
+package array;%0A%0A/**%0A * leetcode no.581%0A */%0Apublic class ShortestUnsortedContinuousSubarray %7B%0A    public static void main(String%5B%5D args) %7B%0A        int%5B%5D nums = new int%5B%5D %7B2, 3, 3, 2, 4%7D;%0A        System.out.println(findUnsortedSubarray(nums));%0A    %7D%0A%0A    public static int findUnsortedSubarray(int%5B%5D nums) %7B%0A        int n = nums.length, end = -2, beg = -1, max = nums%5B0%5D, min = nums%5Bn - 1%5D;%0A        for (int i = 1; i %3C n; i++) %7B%0A            max = Math.max(max, nums%5Bi%5D);%0A            min = Math.min(min, nums%5Bn - 1 - i%5D);%0A            if (nums%5Bi%5D %3C max) end = i;%0A            if (nums%5Bn - 1 - i%5D %3E min) beg = n - 1 - i;%0A        %7D%0A        return end - beg + 1;%0A    %7D%0A%7D%0A

add leetcode no.581