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<=10^{9}

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(LogN)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def isTidy(self,N):
        #code here

Solutions:
class Solution:

	def isTidy(self, N):
		a = str(N)
		n = sorted(str(N))
		l1 = list(a)
		l2 = list(n)
		if l1 == l2:
			return 1
		else:
			return 0


class Solution:

	def isTidy(self, N):
		s = list(str(N))
		if s == sorted(s):
			return 1
		return 0


class Solution:

	def isTidy(self, N):
		N = str(N)
		o = list(N)
		n = sorted(o)
		if o == n:
			return '1'
		else:
			return '0'


class Solution:

	def isTidy(self, N):
		st = str(N)
		for i in range(len(st) - 1):
			if st[i] > st[i + 1]:
				return 0
		return 1


class Solution:

	def isTidy(self, N):
		d = [int(x) for x in str(N)]
		for i in range(len(d) - 1):
			if d[i + 1] < d[i]:
				return 0
				break
		return 1


class Solution:

	def isTidy(self, N):
		while N > 0:
			i = N % 10
			N = int(N / 10)
			i1 = N % 10
			if i1 > i:
				return 0
		return 1


class Solution:

	def isTidy(self, N):
		prev = N % 10
		N = N // 10
		while N != 0:
			r = N % 10
			if r > prev:
				return 0
			prev = r
			N = N // 10
		return 1


class Solution:

	def isTidy(self, N):
		return 1 if str(N) == ''.join(sorted(str(N))) else 0


class Solution:

	def isTidy(self, N):
		li = []
		while N:
			d = N % 10
			N = N // 10
			li.append(d)
		li = li[::-1]
		d = sorted(li)
		if li == d:
			return 1
		else:
			return 0


class Solution:

	def isTidy(self, N):
		x = []
		while N > 0:
			x.append(N % 10)
			N //= 10
		for i in range(len(x) - 1):
			if x[i] < x[i + 1]:
				return 0
		return 1


class Solution:

	def isTidy(self, N):
		N = str(N)
		l = [*N]
		m = map(int, l)
		z = list(m)
		x = z.copy()
		x.sort()
		if x == z:
			return 1
		else:
			return 0


class Solution:

	def isTidy(self, N):
		arr = list(str(N))
		arr.sort()
		N1 = ''.join(arr)
		if int(N1) == N:
			return 1
		else:
			return 0


class Solution:

	def isTidy(self, N: int) -> int:
		previous_digit = N % 10
		N //= 10
		while N:
			digit = N % 10
			if digit > previous_digit:
				return 0
			else:
				previous_digit = digit
			N //= 10
		return 1


class Solution:

	def isTidy(self, N):
		N = list(map(int, list(str(N))))
		for i in range(1, len(N)):
			if N[i - 1] > N[i]:
				return 0
		return 1


class Solution:

	def isTidy(self, n):
		c = n
		n = list('' + str(n))
		n.sort()
		n = int(''.join(n))
		if n == c:
			return 1
		else:
			return 0


class Solution:

	def isTidy(self, N):
		s = str(N)
		s1 = sorted(s)
		s1 = ''.join(s1)
		return int(s1 == s)


class Solution:

	def isTidy(self, N):
		l = list(str(N))
		l1 = [int(i) for i in l]
		l2 = l1[:]
		l2.sort()
		if l1 == l2:
			return 1
		else:
			return 0


class Solution:

	def isTidy(self, N):
		self.N = N
		l = [int(x) for (a, x) in enumerate(str(self.N))]
		k = 1
		for i in range(1, len(l)):
			if l[i - 1] > l[i]:
				return 0
			else:
				k += 1
		if k == len(l):
			return 1


class Solution:

	def isTidy(self, N):
		pre = 99999999999
		while N:
			if N % 10 > pre:
				return 0
			pre = N % 10
			N = int(N / 10)
		return 1


class Solution:

	def isTidy(self, N):
		x = sorted(list(str(N)))
		x = int(''.join(x))
		if N == x:
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isTidy(N))


class Solution:

	def isTidy(self, N):
		s = str(N)
		l = []
		l1 = []
		for i in s:
			l.append(int(i))
			l1.append(int(i))
		l1.sort()
		if l == l1:
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isTidy(N))


class Solution:

	def isTidy(self, N):
		l = [int(i) for i in str(N)]
		if l == sorted(l):
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isTidy(N))


class Solution:

	def isTidy(self, N):
		b = str(N)
		c = ''
		d = ''
		for i in b:
			if i >= d:
				c += i
			else:
				c = ''
				break
			d = i
		if len(c) == 0:
			return 0
		else:
			return 1
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isTidy(N))


class Solution:

	def isTidy(self, N):
		count = 0
		s = str(N)
		for i in range(1, len(s)):
			if s[i - 1] <= s[i]:
				count += 1
		if count + 1 == len(s):
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isTidy(N))


class Solution:

	def isTidy(self, N):
		prev = 10
		while N > 0:
			rem = N % 10
			N = N // 10
			if rem > prev:
				return 0
			prev = rem
		return 1
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isTidy(N))


class Solution:

	def isTidy(self, N):
		s = str(N)
		l = list(map(int, s))
		c = 0
		if len(l) == 1:
			return 1
		for i in range(len(l) - 1):
			if l[i] <= l[i + 1]:
				c += 1
			else:
				c = 0
				break
		if c > 0:
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isTidy(N))


class Solution:

	def isTidy(self, N):
		N = str(N)
		if len(N) == 1:
			return 1
		N = N[::-1]
		flag = False
		for i in range(len(N) - 1):
			if int(N[i]) >= int(N[i + 1]):
				flag = True
			else:
				flag = False
				break
		if flag == True:
			return 1
		return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isTidy(N))


class Solution:

	def isTidy(self, N):
		s = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
		d = str(N)
		n = len(d)
		for i in range(n - 1):
			if s[d[i]] > s[d[i + 1]]:
				return 0
		return 1
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isTidy(N))


class Solution:

	def isTidy(self, N):
		n = str(N)
		i = 1
		while i < len(n):
			if n[i - 1] > n[i]:
				return 0
			i += 1
		return 1


class Solution:

	def isTidy(self, n):
		while True:
			n1 = n % 10
			n = int(n / 10)
			n2 = n % 10
			if n2 > n1:
				return 0
			if n == 0:
				break
		return 1


class Solution:

	def isTidy(self, N):
		x = str(N)
		res = int(x[-1]) + 1
		while N:
			rem = N % 10
			N = N // 10
			if rem <= res:
				res = rem
			else:
				return 0
		return 1


class Solution:

	def isTidy(self, N):
		num1 = N % 10 + 1
		while N > 0:
			if N % 10 > num1:
				break
			num1 = N % 10
			N = N // 10
		if N == 0:
			return 1
		else:
			return 0


class Solution:

	def isTidy(self, N):
		c = 1
		a = []
		s = str(N)
		for i in s:
			a.append(int(i))
		for i in range(len(a) - 1):
			if a[i] <= a[i + 1]:
				c = c + 1
			else:
				return 0
		if c == len(s):
			return 1
		else:
			return 0