Java 98% Faster
Code\n\nclass Solution {\n    public String convertToBase7(int num) {\n        StringBuilder sb = new StringBuilder();\n        while(Math.abs(num) > 6) {\n    
# Code\n```\nclass Solution {\n    public String convertToBase7(int num) {\n        StringBuilder sb = new StringBuilder();\n        while(Math.abs(num) > 6) {\n            sb.append(num % 7);\n            num = num / 7;\n        }\n        if (num < 0) {\n            sb.append(Math.abs(num)).append("-");\n        } else {\n            sb.append(num);\n        }\n        for (int i = 0; i < sb.length() - 1; i++) {\n            if (!Character.isDigit(sb.charAt(i))) {\n                sb.replace(i, i + 1, "");\n            }\n        }\n        return sb.reverse().toString();\n    }\n}\n```
['Java']