From 5e27d21b8cafa6144392e332545d1ae2a6d8f769 Mon Sep 17 00:00:00 2001 From: Azureki Date: Fri, 24 Aug 2018 20:28:23 +0800 Subject: [PATCH] Reordered Power of 2 --- lc869.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lc869.py diff --git a/lc869.py b/lc869.py new file mode 100644 index 0000000..ff3f878 --- /dev/null +++ b/lc869.py @@ -0,0 +1,17 @@ +from collections import Counter + +# Counter 检查数量是否相等,返回一个字典对象(数据结构是散列表) +class Solution: + def reorderedPowerOf2(self, N): + """ + :type N: int + :rtype: bool + """ + count_N=Counter(str(N)) + # any: 只要有一个True,就返回True,全部为False,则返回False + return any(count_N==Counter(str(1<