C++ BEST SOLUTION || EASY APPROACH || O(log base 7)
Intuition\n Describe your first thoughts on how to solve this problem. \nbasic convesion technique is used by dividing the num by 7 and storing the remainder as
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nbasic convesion technique is used by dividing the num by 7 and storing the remainder as a string.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nfirstly the number is converted to base 7 then it is checked if it was a negetive integer then a neetive string is added to the resultant string else the original string is returned.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(log base 7)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    string convertToBase7(int n) {\n        string str="";\n        int rem;\n        int num=abs(n);\n        if(n==0) return "0";\n        while(num!=0){\n            rem=num%7;\n            str=to_string(rem)+str;\n            num/=7;\n        }\n        if(n<0) return "-"+str;\n        return str;\n    }\n};\n```
['Math', 'String', 'C++']