Fastest |JAVA | 0ms
\nclass Solution {\n    public String convertToBase7(int num) {\n        if(num == 0){\n            return "0";\n        }\n        StringBuilder sb = new Strin
```\nclass Solution {\n    public String convertToBase7(int num) {\n        if(num == 0){\n            return "0";\n        }\n        StringBuilder sb = new StringBuilder();\n        boolean isNeg = num < 0;\n        num = Math.abs(num);\n        while(num != 0){\n            sb.append(num%7);\n            num = num/7;\n        }\n        if(isNeg)\n            sb.append(\'-\');\n        return sb.reverse().toString();\n    }\n}\n```
[]