Skip to content

Commit 905436e

Browse files
JS Problem#1 (#2) (#30)
1 parent 772a64e commit 905436e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Python/isPalindrome.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
#Name: Abdullah Yaqub
2+
#Username: AbdullahYaqub72
3+
#Approach: Comparing arrays while traversing in forward and reverse order
4+
15
class Solution:
2-
def isPalindrome(self, x: int) -> bool:
3-
flag=True
4-
y=str(x)
5-
for i in range(0,len(y)-1):
6+
def isPalindrome(self, num: int) -> bool:
7+
isPalind=True
8+
y=str(num)
9+
for i in range(len(y)-1):
610
ind=len(y)-i-1
7-
if(y[i]==y[ind]):
8-
flag=True
9-
else:
10-
flag=False
11+
if(y[i]!=y[ind]):
12+
isPalind=False
1113
break
12-
return flag
14+
else:
15+
isPalind=True
16+
17+
return isPalind

0 commit comments

Comments
 (0)