getting runtime exception in code when running
exception occurred while getting input from scanner please explain
getting runtime exception in code when running
exception occurred while getting input from scanner please explain
@dheerajmishra992 Exception occurred because your logic is wrong bro! That’s why index out of bound occurred because you are checking arr[si] > arr[si + 1], now when si = last index then si+ 1 will check for index which is not even present.
So your base case should be if n == arr.length - 1.