Solved both the question first and second.
In first answer code will reverse each possible pair of 3 and directly reverse the remaining number and will return the required output array.
In second answer I am comparing each number in array with the number which is right side of that number.
logic( arr[i]>=arr[i+1]);
output- array of all leaders.
Solved both the question first and second. In first answer code will reverse each possible pair of 3 and directly reverse the remaining number and will return the required output array. In second answer I am comparing each number in array with the number which is right side of that number. logic( arr[i]>=arr[i+1]); output- array of all leaders.