504. Base 7
来源:互联网 发布:centos忘记密码 编辑:程序博客网 时间:2024/05/16 07:37
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].
class Solution {public: string convertToBase7(int num) { if(num == 0){ return "0"; } string res; int abs_num = abs(num); while(abs_num > 0){ string temp = to_string(abs_num % 7); res = temp + res; abs_num /= 7; } return num >= 0 ? res : '-' + res; }};
阅读全文
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
- 2017乌鲁木齐网络赛 skiing(spfa/bellman最长路模板题)
- hdu6201(无向图最长路)
- 使用thymeleaf在页面直接获取当前时间并格式化输出
- 输入一个int型的正整数,计算出该int型数据在内存中存储时1的个数。
- xmemcached主要用法及与Spring集成--总结
- 504. Base 7
- c++ map
- 自定义Adapter的getView方法的含义
- 难以分类编程题(不断更新)
- 腾讯2018校招WEB前端开发笔试有感
- javastript实现栈
- 智慧教室与未来教育
- POJ 3261 Milk Patterns 后缀数组+二分
- 设计模式六大原则