Skip to content

Commit

Permalink
tanyagupta0201#453 create 2443_sum_of_number_and_its_reverse.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyush146 authored Oct 27, 2022
1 parent 61b130d commit 8992772
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions C++/2443_sum_of_number_and_its_reverse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution {
public:
bool sumOfNumberAndReverse(int n) {
int i;
if(n==0)
return 1;
for(i=1;i<=n;i++)
{
int d,r=0,p=i;
while(p>0)
{
d=p%10;
r=r*10+d;
p=p/10;
}
if((r+i)==n)
return 1;
}
return 0;
}
};

0 comments on commit 8992772

Please sign in to comment.