File tree Expand file tree Collapse file tree 1 file changed +21
-13
lines changed Expand file tree Collapse file tree 1 file changed +21
-13
lines changed Original file line number Diff line number Diff line change 66#         """ 
77
88class  Solution (object ):
9-     def  isPalindrome (self , x ):
10-         if  x  <  0 :
11-             return  False 
12-         ls  =  len (str (x ))
13-         tmp  =  x 
14-         for  i  in  range (int (ls / 2 )):
15-             right  =  int (tmp  %  10 )
16-             left  =  tmp  /  (10  **  (ls  -  2  *  i  -  1 ))
17-             left  =  int (left  %  10 )
18-             if  left  !=  right :
19-                 return  False 
20-             tmp  =  tmp  //  10 
21-         return  True 
9+     def  isPalindrome (self , x : int ) ->  bool :
10+         x  =  str (x )
11+         if  (x  ==  x [::- 1 ]):
12+             return  True 
13+         return  False         
14+         
15+         
16+     # def isPalindrome(self, x): 
17+     #     if x < 0: 
18+     #         return False 
19+     #     ls = len(str(x)) 
20+     #     tmp = x 
21+     #     for i in range(int(ls/2)): 
22+     #         right = int(tmp % 10) 
23+     #         left = tmp / (10 ** (ls - 2 * i - 1)) 
24+     #         left = int(left % 10) 
25+     #         if left != right: 
26+     #             return False 
27+     #         tmp = tmp // 10 
28+     #     return True 
29+     
2230
2331    # def isPalindrome(self, x): 
2432    #     #leetcode book 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments