Question: Please answer all questions in C++. Write a program that takes in an array of numbers separated by commas. Suppose the numbers in the array
Please answer all questions in C++. Write a program that takes in an array of numbers separated by commas. Suppose the numbers in the array are indexed starting from zero (as they are in C++).
Your program needs to identify the start and end indices of the smallest sub-array which when sorted will result in the whole input array to be sorted.
For example, if we input the following array:
1,2,3,6,5,4,7,8,9
Then the smallest sub-array which needs to be sorted would start at index 3 and end at index 5.
Therefore the output is
3 5
Here are more examples of Input and output for this problem.
Input: 1,3,8,9,10,14,7,18,20
Output: 2 6
Input: 3,4,6,7,9,10,12,15,12,63,5,11,64
Output: 2 11
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
