Given a number N.Find if the digit sum(or sum of digits) of N is a Palindrome number or not.
Note:A Palindrome number is a number which stays the same when reversed.Example- 121,131,7 etc.
Example 1:
Input:
N=56
Output:
1
Explanation:
The digit sum of 56 is 5+6=11.
Since, 11 is a palindrome number.Thus,
answer is 1.
Example 2:
Input:
N=98
Output:
0
Explanation:
The digit sum of 98 is 9+8=17.
Since 17 is not a palindrome,thus, answer
is 0.
Your Task:
You don't need to read input or print anything.Your Task is to complete the function isDigitSumPalindrome() which takes a number N as input parameter and returns 1 if the Digit sum of N is a palindrome.Otherwise it returns 0.
Expected Time Complexity:O(LogN)
Expected Auxillary Space:O(1)
Constraints:
1<=N<=10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def isDigitSumPalindrome(self,N):

        #code here

Solutions:
class Solution:

	def isDigitSumPalindrome(self, n):
		t = 0
		for i in str(n):
			t += int(i)
		return 1 if str(t) == str(t)[::-1] else 0


class Solution:

	def isDigitSumPalindrome(self, N):
		digits = [int(x) for x in str(N)]
		value = sum(digits)
		newlist = [int(x) for x in str(value)]
		if newlist == newlist[::-1]:
			return 1
		return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		su = 0
		while N > 0:
			n = N % 10
			su = su + n
			N = N // 10
		st = str(su)
		strev = st[::-1]
		finalint = int(strev)
		if finalint == su:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		temp = N
		while temp != 0:
			digit = temp % 10
			sum += digit
			temp = temp // 10
		temp = sum
		res = 0
		while temp != 0:
			digit = temp % 10
			res = res * 10 + digit
			temp = temp // 10
		return 1 if res == sum else 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		while N > 0:
			rem = N % 10
			sum = sum + rem
			N = N // 10
		return 1 if str(sum) == str(sum)[::-1] else 0


class Solution:

	def isDigitSumPalindrome(self, N):
		n = str(N)
		if len(n) > 1:
			s = 0
			for i in n:
				s += int(i)
			s = str(s)
			if s == s[::-1]:
				return 1
			else:
				return 0
		else:
			return 1


class Solution:

	def isDigitSumPalindrome(self, N):
		var = 0
		for i in str(N):
			var += int(i)
		var = str(var)
		for i in range(len(var) // 2):
			if var[i] != var[len(var) - i - 1]:
				return 0
		return 1


class Solution:

	def isDigitSumPalindrome(self, N):
		(N, Sum) = (str(N), 0)
		for i in range(len(N)):
			Sum += int(N[i])
		return 1 if str(Sum) == str(Sum)[::-1] else 0


class Solution:

	def isDigitSumPalindrome(self, N):
		no = N
		sum = 0
		while no > 0:
			dig = no % 10
			sum = sum + dig
			no = no // 10
		wno = sum
		rev = 0
		while sum > 0:
			dig1 = wno % 10
			sum = sum // 10
			rev = rev * 10 + dig1
		if rev == wno:
			return '1'
		else:
			return '0'


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		while N > 0:
			sum += N % 10
			N //= 10
		num = sum
		psum = 0
		while num > 0:
			psum = psum * 10 + num % 10
			num //= 10
		if sum == psum:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		s = 0
		while N != 0:
			a = N % 10
			s = s + a
			N = N // 10
		c = str(s)
		str_rev = c[::-1]
		if c == str_rev:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		for i in str(N):
			sum = sum + int(i)
			rev = int(str(sum)[::-1])
		if rev == sum:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		while N > 0:
			rem = N % 10
			sum = sum + rem
			N = int(N / 10)
		res = 0
		temp = sum
		palin = 0
		while temp > 0:
			rem = temp % 10
			palin = palin * 10 + rem
			temp = int(temp / 10)
		if palin == sum:
			res = 1
		return res


class Solution:

	def sum(self, N):
		number = 0
		n = N
		while N > 0:
			number += N % 10
			N = N // 10
		return number

	def isDigitSumPalindrome(self, N):
		x = self.sum(N)
		y = x
		digit = 0
		while x != 0:
			numbers = x % 10
			digit = digit * 10 + numbers
			x = x // 10
		if y == digit:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		n1 = N
		s = 0
		while n1:
			s += n1 % 10
			n1 //= 10
		(s1, s2) = (s, 0)
		while s:
			s2 = s2 * 10 + s % 10
			s //= 10
		if s1 == s2:
			return 1
		return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		num = N
		sum = 0
		while num > 0:
			sum += num % 10
			num = int(num / 10)
		list = []
		for a in range(len(str(sum))):
			list.append(str(sum)[a])
		list_2 = []
		for z in range(1, len(list) + 1):
			list_2.append(list[len(list) - z])
		if list == list_2:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		digit_sum = 0
		n = N
		while n > 0:
			digit_sum += n % 10
			n = int(n / 10)
		if str(digit_sum)[::-1] == str(digit_sum):
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		count = 0
		N = str(N)
		for i in N:
			count += int(i)
		count = str(count)
		if count == count[::-1]:
			return 1
		return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		s = str(N)
		sum = 0
		for i in s:
			sum = sum + int(i)
		ssum = str(sum)
		sssum = ssum[::-1]
		if ssum == sssum:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		s = str(N)
		num = 0
		for i in s:
			num += int(i)

		def isSingle(num):
			return num // 10 == 0

		def isPal(num, dupNum):
			if isSingle(num):
				return num == dupNum[0] % 10
			if not isPal(num // 10, dupNum):
				return False
			dupNum[0] = dupNum[0]
			return num % 10 == dupNum[0] % 10
		dupNum = [num]
		if isPal(num, dupNum):
			return 1
		return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		s = 0
		for digit in str(N):
			s += int(digit)
		if str(s) == str(s)[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		s = 0
		while N > 0:
			a = N % 10
			s += a
			N = N // 10
		conv = str(s)
		rev = conv[::-1]
		if rev == conv:
			return 1
		return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		n = N
		s = 0
		while n > 0:
			r = n % 10
			s += r
			n = n // 10
		n = s
		rev = 0
		while n > 0:
			r = n % 10
			rev = rev * 10 + r
			n = n // 10
		if rev == s:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum1 = 0
		while N > 0:
			sum1 += N % 10
			N = N // 10
		if str(sum1) == str(sum1)[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		Nstr = str(N)
		Nmap = list(map(int, Nstr))
		Nsum = sum(Nmap)
		temp_n = Nsum
		rev = 0
		while Nsum > 0:
			div = Nsum % 10
			rev = rev * 10 + div
			Nsum = Nsum // 10
		if temp_n == rev:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		y = 1
		n = 0
		while N > 0:
			k = N % 10
			sum = sum + k
			N = N // 10
		string = str(sum)
		if string == string[::-1]:
			return y
		else:
			return n


class Solution:

	def isDigitSumPalindrome(self, N):
		e = 0
		a = str(N)
		for i in range(len(a)):
			e = e + int(a[i])
		b = str(e)
		d = b[::-1]
		if b == d:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		summ = 0
		t = N
		while t >= 1:
			summ += t % 10
			t = t // 10
		t = summ
		p = 0
		while t >= 1:
			p = p * 10 + t % 10
			t = t // 10
		if p == summ:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		str1 = str(N)
		add = 0
		for i in str1:
			n = N % 10
			add = add + n
			N = N // 10
		temp = add
		str2 = str(add)
		res = 0
		for i in range(0, len(str2)):
			n1 = add % 10
			res = res * 10 + n1
			add = add // 10
		if temp == res:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		n_str_list = list(str(N))
		suma = 0
		for i in n_str_list:
			suma += int(i)
		i_str_list = list(str(suma))
		i = 0
		j = len(i_str_list) - 1
		while i < j:
			if not i_str_list[i] == i_str_list[j]:
				return 0
			i += 1
			j -= 1
		return 1


class Solution:

	def isDigitSumPalindrome(self, n):
		n = list(str(n))
		n = sum(map(int, n))
		n1 = str(n)
		return 1 if n1 == n1[::-1] else 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		while N > 0:
			k = N % 10
			sum += k
			N //= 10
		b = sum
		tot = 0
		while sum > 0:
			n = sum % 10
			tot = tot * 10 + n
			sum //= 10
		if tot == b:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, n):

		def number(n):
			num = 0
			while n:
				l = n % 10
				num = num + l
				n = n // 10
			return num
		num = number(n)
		m = num
		k = 0
		while m:
			o = m % 10
			k = k * 10 + o
			m = m // 10
		if num == k:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		for i in str(N):
			sum = sum + int(i)
		temp = sum
		reverse = 0
		while temp > 0:
			reverse = reverse * 10 + temp % 10
			temp = temp // 10
		if reverse == sum:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		list1 = []
		for i in str(N):
			list1.append(int(i))
		sum1 = sum(list1)
		a = str(sum1)
		if a == a[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum1 = sum([int(x) for x in str(N)])
		a = str(sum1)
		if a == a[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum1 = 0
		temp = N
		while temp > 0:
			sum1 = sum1 + temp % 10
			temp = temp // 10
		sumtemp = sum1
		reverse = 0
		reminder = 0
		while sumtemp > 0:
			reminder = sumtemp % 10
			reverse = reverse * 10 + reminder
			sumtemp = sumtemp // 10
		if sum1 == reverse:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		st1 = str(N)
		sum1 = 0
		for i in st1:
			sum1 += int(i)
		if str(sum1) == str(sum1)[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		cn = str(N)
		sum = 0
		for i in cn:
			sum += int(i)
		cs = str(sum)
		rcs = cs[::-1]
		if cs == rcs:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		s = 0
		while N > 0:
			d = N % 10
			s += d
			N = N // 10
		x = s
		z = s
		reverse = 0
		while x > 0:
			digit = x % 10
			reverse = reverse * 10 + digit
			x = x // 10
		if z == reverse:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		nit = str(N)
		res = 0
		for i in nit:
			res += int(i)
		if str(res) == str(res)[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		while N > 0:
			r = N % 10
			sum += r
			N = N // 10
		s = str(sum)
		if s == s[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		while N > 0:
			sum = sum + N % 10
			N = N // 10
		rev = str(sum)
		if sum == int(rev[::-1]):
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		num = N
		summ = 0
		while num > 0:
			(dig, num) = (num % 10, num // 10)
			summ += dig
		num = summ
		rev = 0
		while num > 0:
			(rem, num) = (num % 10, num // 10)
			rev = rev * 10 + rem
		if rev == summ:
			return 1
		return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		num_str = str(N)
		total = 0
		for i in num_str:
			total += int(i)
		if total == int(str(total)[::-1]):
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		s = p = 0
		while N > 0:
			r = N % 10
			N = int(N / 10)
			s = s + r
		temp = s
		while s > 0:
			r = s % 10
			s = int(s / 10)
			p = p * 10 + r
		if p == temp:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		c = 0
		a = str(N)
		b = list(a)
		for i in b:
			c += int(i)
		d = str(c)[::-1]
		if int(c) == int(d):
			return 1
		return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		s = 0
		for i in str(N):
			a = int(i)
			s = s + a
		c = str(s)
		if str(s) == c[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		while N != 0:
			rem = N % 10
			sum = sum + rem
			N = int(N / 10)
		a = str(sum)
		b = a[::-1]
		if a == b:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		total = 0
		for ch in str(N):
			total += int(ch)
		total = str(total)
		return int(total == total[::-1])


class Solution:

	def isDigitSumPalindrome(self, N):
		numstr = str(N)
		sum = 0
		temp = 0
		for i in range(0, len(numstr)):
			temp = int(numstr[i])
			sum = sum + temp
		sumstr = str(sum)
		if sumstr[::1] == sumstr[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		temp_num = N
		digital_sum = 0
		while temp_num != 0:
			digital_sum += temp_num % 10
			temp_num //= 10
		reverse_num = self.reverse_digit(digital_sum)
		return 1 if digital_sum == reverse_num else 0

	def reverse_digit(self, num_rev):
		reverse_number = 0
		while num_rev != 0:
			reverse_number = reverse_number * 10 + num_rev % 10
			num_rev = num_rev // 10
		return reverse_number


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		reverse_sum = 0
		while N != 0:
			sum += N % 10
			N //= 10
		x = sum
		while x != 0:
			reverse_sum = reverse_sum * 10 + x % 10
			x //= 10
		return 1 if sum == reverse_sum else 0


class Solution:

	def sum_results(self, N):
		N = str(N)
		if len(N) == 1:
			return int(N)
		else:
			results = int(N[0]) + self.sum_results(N[1:])
		return int(results)

	def isDigitSumPalindrome(self, N):
		number = self.sum_results(N)
		original_result = number
		i = 0
		while number > 0:
			i = i * 10 + number % 10
			number = number // 10
		if i == original_result:
			return 1
		else:
			return 0


class Solution:

	def sumOfDigits(self, N):
		(temp, total) = (N, 0)
		while temp > 0:
			digit = temp % 10
			total = total + digit
			temp //= 10
		return total

	def isDigitSumPalindrome(self, N):
		digit_sum = self.sumOfDigits(N)
		(temp, rev) = (digit_sum, 0)
		while temp > 0:
			digit = temp % 10
			rev = rev * 10 + digit
			temp //= 10
		if rev == digit_sum:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		x = 0
		for i in str(N):
			x += int(i)
		x = str(x)
		if x == x[::-1]:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		while N > 0:
			digit = N % 10
			sum += digit
			N = N // 10
		r = sum
		rev = 0
		while r > 0:
			d = r % 10
			rev = rev * 10 + d
			r = r // 10
		if sum == rev:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		m = N
		n = 0
		while m > 0:
			n = n + m % 10
			m = m // 10
		o = n
		p = 0
		while o > 0:
			p = p * 10 + o % 10
			o = o // 10
		if p == n:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		ntos = str(N)
		for i in ntos:
			sum += int(i)
		if sum < 10:
			return 1
		isOdd = True if len(str(sum)) % 2 != 0 else False
		mid = int(len(str(sum)) + 1 / 2) if isOdd else int(len(str(sum)) / 2)
		skew = 0
		for (i, v) in enumerate(str(sum)):
			if i == mid - 1 and isOdd:
				continue
			if i <= mid - 1:
				skew += int(v)
			else:
				skew -= int(v)
		return 1 if skew == 0 else 0


class Solution:

	def isDigitSumPalindrome(self, N):
		sum = 0
		temp = 0
		while N > 0:
			last = N % 10
			sum += last
			N = N // 10
		sum = str(sum)
		s = sum[::-1]
		if sum == s:
			return 1
		else:
			return 0


class Solution:

	def isDigitSumPalindrome(self, N):
		t = N
		sum = 0
		while t > 0:
			d = t % 10
			sum += d
			t //= 10
		s = str(sum)
		if s == s[::-1]:
			return 1
		else:
			return 0