diff --git a/1574. Shortest Subarray to be Removed to Make Array Sorted b/1574. Shortest Subarray to be Removed to Make Array Sorted new file mode 100644 index 0000000..2e91d52 --- /dev/null +++ b/1574. Shortest Subarray to be Removed to Make Array Sorted @@ -0,0 +1,34 @@ +class Solution { +public: + int findLengthOfShortestSubarray(vector& arr) { + //find first ans last decreasing pair + int first=-1; + int last=-1; + int n=arr.size(); + for(int i=0;iarr[i+1]){ + if(first==-1){ + first=i; + } + last=i; + } + } + if (first == -1) { + return 0; + } +// now find the max len of non decreasing array that does not has these pair + + int ans=min(last+1,n-first-1); + for(int i=0;i<=first;i++){ + for(int j=last+1;j