504. Base 7
来源:互联网 发布:可以做seo的淘宝客cms 编辑:程序博客网 时间:2024/06/08 06:56
Given an integer, return its base 7 string representation.
Example 1:
Input: 100Output: "202"
Example 2:
Input: -7Output: "-10"
Note: The input will be in range of [-1e7, 1e7].
public class Solution { public String convertToBase7(int num) { StringBuilder sb = new StringBuilder(); StringBuilder r = new StringBuilder(); if (num == 0) return "0"; if (num < 0) { r.append('-'); num = -num; } while (num != 0) { sb.append((char)(num % 7 + '0')); num /= 7; } return r.append(sb.reverse()).toString(); }}
阅读全文
0 0
- Leetcode-504. Base 7
- 【Leetcode】504. Base 7
- LeetCode 504. Base 7
- 504. Base 7
- [leetcode]504. Base 7
- 504. Base 7
- 504. Base 7
- 504. Base 7
- 504. Base 7
- LeetCode-504. Base 7
- 504. Base 7
- 504. Base 7
- 504. Base 7
- leetcode 504. Base 7
- 504. Base 7
- LeetCode:504. Base 7
- [LeetCode]504. Base 7
- leetcode 504. Base 7
- JQuery 实现 图片滑动收起与隐藏
- 文章标题n个人围成一圈,顺序排号。从第一个人开始报数(1~3),凡报到3的人退出圈子,问最后留下来的是原来几号的那位?
- 域名动态解析到动态IP
- nodejs版 阿里云开放api签名算法
- C++引用解析
- 504. Base 7
- 进程间通信——消息队列
- python中的函数
- Flask和Ajax的交互
- 十道海量数据处理面试题与十个方法大总结
- 模板的类型萃取
- 百炼-2773-采药-C语言-01背包
- 进程间通信——共享内存
- 函数指针与指针函数