Leaderboard
Showing:
Tidy Number
Basic Accuracy: 29.82% Submissions: 171 Points: 1

Given a number N.Check if it is tidy or not.
A tidy number is a number whose digits are in non-decreasing order.

Example 1:

Input: 
1234
Output:
1
Explanation:
Since 1<2<3<4,therefore the number is tidy.

Example 2:

Input: 
1243
Output:
0
Explanation:
4>3, so the number is not tidy.


Your Task:
You don't need to read input or print anything.Your task is to complete the function isTidy() which takes an Integer N as input parameter and returns 1 if it is tidy.Otherwise, it returns 0.


Expected Time Complexity:O(LogN)
Expected Auxillary Space:O(1)


Constraints:
1<=N<=109

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Tidy Number

Output Window