504. Base 7
来源:互联网 发布:淘宝店铺装修尺寸 编辑:程序博客网 时间:2024/06/16 05: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].
Subscribe to see which companies asked this question.
public class Solution { public String convertToBase7(int num) { if (num == 0)return "0";StringBuilder re = new StringBuilder();boolean flag = false;if (num < 0) {flag = true;num = -num;}while (num != 0) {re.insert(0, num % 7);num /= 7;}if (flag)re.insert(0, '-');return re.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
- angular directive
- jquery函数
- 求一个数组的最大公约数
- 监听
- 常用正则表达式
- 504. Base 7
- QT数据库连接必备QSqlDatabase
- Camtasia Studio 9.0.3 中文汉化版安装教程(屏幕录像软件)
- 第十一章:DOM扩展
- Spark ConfigEntry
- 欢迎使用CSDN-markdown编辑器
- iOS项目代码行数统计
- 【linux is not Unix】windows部署——softether服务端安装
- 天线设计(3)