Advertisement
sajid161

4:3

Dec 31st, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. class Solution {
  2.   public:
  3.     int isDigitSumPalindrome(int N) {
  4.         string str,st,st1;
  5.         str=to_string(N);
  6.         int sum=0;
  7.         for(int i=0;i<str.size();i++)
  8.         {
  9.             int a=str[i]-'0';
  10.             sum+=a;
  11.         }
  12.         st=to_string(sum);
  13.         st1=st;
  14.         reverse(st1.begin(),st1.end());
  15.         if(st1==st) return 1;
  16.         else return 0;
  17.     }
  18. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement