(Leetcode)504. Base 7
来源:互联网 发布:51建库软件 编辑:程序博客网 时间:2024/06/04 19:32
Given an integer, return its base 7 string representation.
Example 1:
Input: 100
Output: "202"
Example 2:
Input: -7
Output: "-10"
Solution:
public class Solution { public String convertToBase7(int num) { StringBuilder sb = new StringBuilder(); boolean flag = true; // 标记num 符号 if (num == 0){ return "0"; } if(num < 0) { flag = false; } while (num != 0) { sb.append(Math.abs(num) % 7); num = num / 7; } if (!flag) { return "-" + sb.reverse().toString(); } return sb.reverse().toString(); }}
阅读全文
0 0
- Leetcode-504. Base 7
- 【Leetcode】504. Base 7
- LeetCode 504. Base 7
- [leetcode]504. Base 7
- LeetCode-504. Base 7
- leetcode 504. Base 7
- LeetCode:504. Base 7
- [LeetCode]504. Base 7
- leetcode 504. Base 7
- [leetcode]: 504. Base 7
- (Leetcode)504. Base 7
- LeetCode 504. Base 7
- leetcode 504. Base 7
- leetcode:504. Base 7
- [leetcode]504. Base 7
- leetcode 504. Base 7
- LeetCode 504. Base 7
- 【LeetCode】 504. Base 7
- 主定理——学习笔记
- shiro多realm配置(可区分不同类型用户)
- 二分图及其匹配算法——最大匹配数(最小覆盖数)、最大独立数、最小路径覆盖、带权最优匹配
- Http协议与Servlet概述[思维导图]
- 如何建立安全通道
- (Leetcode)504. Base 7
- Mac系统如何完美安装PHP7
- 无需安装,利用Ubuntu建立WiFi热点 Creating wifi-hotspot with Ubuntu without downloading
- KS值
- 我的学习之路_第四章_异常
- 用 Vundle 管理 VIM 插件
- jar命令的使用
- harproxy记录log
- 注解(Annotation)