This post is completed by 1 user
|
Add to List |
231. Check if array is sorted using recursion
Objective: Given an array of integers write a recursive solution to check if the array is sorted.
Example:
int [] a = {1,2,3,4}; Output: true int [] a = {1,2,3,4,2}; Output: false
Approach: This problem can easily be solved in a single iteration by just comparing adjacent elements. The fun part is to write the recursive solution. The code is self-explanatory.
Output:
true