✅ Runtime: 0 ms, faster than 100.00% of C++ online submissions
\n\n/*** 504. Base 7 -  CPP17  ***/\n\nclass Solution {\npublic:\n    string convertToBase7(int num) {\n        string x = "";\n        int temp = 0;\n        i
```\n\n/*** 504. Base 7 -  CPP17  ***/\n\nclass Solution {\npublic:\n    string convertToBase7(int num) {\n        string x = "";\n        int temp = 0;\n        if(num<0){\n            temp=-1*num;\n        }\n        else {\n            temp=num;\n        }\n        vector<int> ans;\n        while(temp>=7){\n            int a = temp%7;\n            ans.push_back(a);\n            temp/=7;\n        }\n        ans.push_back(temp);\n        for(int i=0;i<ans.size();i++){\n            string m = to_string(ans[i]);\n            x+=m;\n        }\n        reverse(x.begin(),x.end());\n        if(num<0){\n            x.insert(x.begin(),\'-\');\n        }\n        return x;\n    }\n};\n\n```
['String', 'C']