Leetcode-Problem-1780__Check-if-Number-is-a-Sum-of-Powers-of-Three__Python3

时间:2021-04-07 14:11:35
【文件属性】:
文件名称:Leetcode-Problem-1780__Check-if-Number-is-a-Sum-of-Powers-of-Three__Python3
文件大小:1KB
文件格式:ZIP
更新时间:2021-04-07 14:11:35
Python Leetcode-Problem-1780__检查数字是否为三的幂之和__Python3 描述 给定一个整数n ,如果可以将n表示为三的幂的和,则返回true。 否则,返回false。 如果存在整数x使得y = 3 ^ x,则整数y是3的幂。 范例1: Input: n = 12 Output: true Explanation: 12 = 3^1 + 3^2 范例2: Input: n = 91 Output: true Explanation: 91 = 3^0 + 3^2 + 3^4 范例3: Input: n = 21 Output: false 限制条件: 1 <= n <= 107 解决方案策略: -Get the ternary representation of the given number _n_ -Check if there is _2_ in th
【文件预览】:
Leetcode-Problem-1780__Check-if-Number-is-a-Sum-of-Powers-of-Three__Python3-main
----solution.py(549B)
----README.md(768B)

网友评论