
g0501_0600.s0504_base_7.Solution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java21 Show documentation
Show all versions of leetcode-in-java21 Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
package g0501_0600.s0504_base_7;
// #Easy #Math #2022_07_24_Time_0_ms_(100.00%)_Space_39.4_MB_(98.67%)
/**
* 504 - Base 7\.
*
* Easy
*
* Given an integer `num`, return _a string of its **base 7** representation_.
*
* **Example 1:**
*
* **Input:** num = 100
*
* **Output:** "202"
*
* **Example 2:**
*
* **Input:** num = -7
*
* **Output:** "-10"
*
* **Constraints:**
*
* * -107 <= num <= 107
**/
public class Solution {
public String convertToBase7(int num) {
return Integer.toString(num, 7);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy