Find Maximum Sum of a Subarray of Size K - https://www.youtube.com/watch?v=li9rcswj0WM
Given an array of unsorted integers. We have to write a code to find minimum length subarray such that if we sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.
We have to return the shortest subarray length.
OR
Find the minimum length unsorted subarray sorting which makes the complete array sorted.
For example -
Example 1:
Input: {0, 2, 5, 4, 9, 6, 12}
Output: 4
Minimum length unsorted SubArray is {5, 4, 9, 6}.
If we sort this subarray in ascending order,
then the whole array will be sorted in ascending order.
Example 2:
Input: {1, 5, 3, 8, 10, 9, 13]
Output: 5
We need to sort this subarray {5, 3, 8, 10, 9} in ascending order to
make the whole array sorted.
Website - https://webrewrite.com/
Paypal - https://www.paypal.me/programmingtutorials