not using binary manipulation, very simple python


  • 0
    P
    bi_num = bin(n)
            re_bi_num = bi_num[::-1]
            for ii in range(len(re_bi_num)):
                temp = re_bi_num[ii]
                if ii+1 < len(re_bi_num) and re_bi_num[ii+1] == temp:
                    return False
                else:
                    continue
            return True
    

Log in to reply
 

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