My python code ,is it legal?


  • 0
    E
    class Solution(object):
    def isPowerOfThree(self, n):
    	if(n>0):
    		while(n!=0):
    			if(n%3!=0 and n!=1):
    				return False
    			else:
    				n = n/3
    		if(True):
    			return True
    	else:
    		return False

  • 1
    D

    I think it is right.
    But the if(True) is redundant.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.