Please enter your email address or userHandle.
Given a Number N in String form, Print 1 If the digits of the number are in non-decreasing or non-increasing order, else print 0.
N = "1233"
The digits of the number are in non-
decreasing order. So, the Output is 1.
N = "1263"
The digits of the number are neither in
non-decreasing nor in non-increasing order.
So, the Output is 0.
You don't need to read input or print anything. Your task is to complete the function difProblem() which takes a String N as input and returns 0 or 1.
Expected Time Complexity: O(|N|)
Expected Auxiliary Space: O(1)
1 <= |N| <= 105
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.