leetcode 869. Reordered Power of 2
function reorderedPowerOf2(N) {
var a1 = N.toString().split('')
a1.sort((a, b) =>
a.localeCompare(b)
)
var s1 = a1.join('')
for (let i = 0; i < 31; i++) {
var a2 = String(1 << i).split('')
a2.sort((a, b) =>
a.localeCompare(b)
)
if (s1 === a2.join(''))
return true;
}
return false;
}
leetcode 869. Reordered Power of 2的更多相关文章
- LC 869. Reordered Power of 2
Starting with a positive integer N, we reorder the digits in any order (including the original order ...
- 【LeetCode】869. Reordered Power of 2 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典统计每位数字出现的次数 日期 题目地址:http ...
- 869. Reordered Power of 2
Starting with a positive integer N, we reorder the digits in any order (including the original order ...
- 【一天一道LeetCode】#342. Power of Four
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- [LeetCode] Reordered Power of 2 重新排序为2的倍数
Starting with a positive integer N, we reorder the digits in any order (including the original order ...
- 【一天一道LeetCode】#231. Power of Two
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- 【一天一道LeetCode】#326. Power of Three
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...
- [Swift]LeetCode869. 重新排序得到 2 的幂 | Reordered Power of 2
Starting with a positive integer N, we reorder the digits in any order (including the original order ...
- 【LeetCode】342. Power of Four 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 迭代 位运算 函数法 日期 [LeetCode ...
随机推荐
- 导航贴 | IT Crypt 密码学优秀博文
Base64编码: 什么是Base64? 一篇文章彻底弄懂Base64编码原理 Morse密码: 看似神秘,实则简单的装逼利器-摩斯密码 Bacon 密码: 密码学笔记 -- 培根密码 RSA 加密: ...
- SpringBoot导出excel数据报错Could not find acceptable representation
转自:https://blog.csdn.net/mate_ge/article/details/93518286?utm_source=distribute.pc_relevant.none-tas ...
- Qt读写文件
1.头文件 #include<QFile> #include<QFileDialog> #include<QDataStream> 2.写代码前工作 在ui界面拖入 ...
- B. Modulo Equality
当时想到的第一个想法是用拓展欧几里得解方程,求x的最小正解.一发交了之后发现爆long long,因为m是1e9. 因此本题的正解是暴力,保证有解的情况下,那么a数组中的一个数必然对应着b数组中的一个 ...
- Wannafly Winter Camp 2020 Day 6D 递增递增 - dp,组合数学
给定两个常为 \(n\) 的序列 \(l_i,r_i\),问夹在它们之间 ( \(\forall i, l_i \leq a_i \leq r_i\) ) 的不降序列的元素总和. Solution 先 ...
- Ansible之优化提升执行效率
今天分享一下Ansible在工作环境中有那些可以优化的配置 环境介绍:以前在公司工作处理服务器问题,需要用批量操作都是用shell脚本编写的工具,后来发现Ansible这个自动化工具,安装简单,操作起 ...
- java线程池之synchronized锁
//Object 定义了一个引用类型的对象用于加锁 static Object Lock = new Object(); //定义一个int类型变量0做初始值 static int iCheck = ...
- thinkphp 5.0 后台数据修改
html代码 <table class="easyui-datagrid" data-options="singleSelect:true,collapsible: ...
- #4864. [BeiJing 2017 Wc]神秘物质 [FHQ Treap]
这题其实挺简单的,有个东西可能稍微难维护了一点点.. \(merge\ x\ e\) 当前第 \(x\) 个原子和第 \(x+1\) 个原子合并,得到能量为 \(e\) 的新原子: \(insert\ ...
- Docker常用命令和功能介绍
可以搜索 dockerfile 定制创建一个redis镜像image 表示镜像docker search 搜索镜像的名称和标签docker 所在目录/var/lib/dockerdocker的镜像文件 ...