All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g0501_0600.s0504_base_7.Solution Maven / Gradle / Ivy

There is a newer version: 1.41
Show newest version
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