C++ iterative and Recursive solution 3 lines code faster than 100%
Iterative approach\n\nclass Solution {\npublic:\n    string convertToBase7(int num) {\n        int res = 0;\n        int p = 1;\n        while(num != 0)\n      
Iterative approach\n```\nclass Solution {\npublic:\n    string convertToBase7(int num) {\n        int res = 0;\n        int p = 1;\n        while(num != 0)\n        {\n            res += (num % 7) * p;\n            num /= 7;\n            p *= 10;\n        }\n        return to_string(res);\n    }\n};\n```\nRecursive approach\n```\nclass Solution {\npublic:\n    string convertToBase7(int n) {\n        if(n < 0) \n        {\n            return "-" + convertToBase7(-n);\n        }\n        else if(n < 7)\n        {\n            return to_string(n);\n        }\n        return convertToBase7(n/7) + to_string(n % 7);\n    }\n};\n```
['Recursion']