当前位置:网站首页>Leetcode- hex number - simple
Leetcode- hex number - simple
2022-06-13 05:49:00 【AnWenRen】
title :504 Octal number - Simple
subject
Given an integer
num, Convert it to 7 Base number , And output... As a string .
Example 1
Input : num = 100
Output : "202"
Example 2
Input : num = -7
Output : "-10"
Tips
-107 <= num <= 107
Code Java
public String convertToBase7(int num) {
StringBuilder sb = new StringBuilder();
int flag = 0;
if (num == 0)
return sb.append(0).toString();
else if (num < 0) {
flag = 1;
num = -num;
}
while (num != 0) {
sb.append(num % 7);
num /= 7;
}
if (flag == 1)
sb.append('-');
return sb.reverse().toString();
}
边栏推荐
- Browser screenshot method (long screenshot, node screenshot, designated area screenshot)
- Comment procéder à l'évaluation des algorithmes
- Leetcode judge subsequence simple
- 为什么那么多人讨厌A-Spice
- Explanation of sentinel series' features, composition and deployment
- Interrupt processing
- A simple recursion problem of linked list
- OpenGL Mosaic (8)
- powershell优化之一:提示符美化
- [China & some provinces and cities] JSON file for offline map visualization
猜你喜欢

Hainan University Postgraduate Entrance Examination electronic information (085400) landing experience

3. Postman easy to use

Concurrent programming -- what is threading?

MongoDB 多字段聚合Group by

Solutions to conflicts between xampp and VMware port 443

How to Algorithm Evaluation Methods

Shardingsphere JDBC < bind table > avoid join Cartesian product

Validation set: ‘flowable-executable-process‘ | Problem: ‘flowable-servicetask-missing-implementatio

Byte buddy print execution time and method link tracking

Three paradigms of MySQL
随机推荐
使用cmake交叉編譯helloworld
Windbos common CMD (DOS) command set
Windbos run command set
11 signalthrowingevent and signalboundaryevent of flowable signal event
890. Find and Replace Pattern
No assessment summary
Anaconda configuring the mirror source
Misunderstanding of tongweb due to ease of use
Implementation of concurrent programming locking
2021.9.29学习日志-Restful架构
@Detailed explanation of propertysource usage method and operation principle mechanism
[China & some provinces and cities] JSON file for offline map visualization
Leetcode- intersection of two arrays ii- simple
MySQL installation in Linux Environment
Quartz basic use
Etcd understanding of microservice architecture
The problem of distinguishing and sharing sessions for multiple applications in tongweb
About Evaluation Metrics
20 flowable container (event sub process, things, sub process, pool and pool)
Application virtual directory static resource configuration on tongweb