Easy and Simple code to solve Base 7.
Intuition\nTo convert a number to base 7, we continuously divide the number by 7 and store the remainder at each step. These remainders represent the digits in 
# Intuition\nTo convert a number to base 7, we continuously divide the number by 7 and store the remainder at each step. These remainders represent the digits in base 7, starting from the least significant digit. If the number is negative, we simply append a minus sign at the end.\n\n# Approach\n1. Handle the base case where the number is 0.\n2. Check if the number is negative and record the sign.\n3. Convert the number to its absolute value and divide it repeatedly by 7. \n4. Collect the remainders at each step, which represent the digits in base 7.\n5. Reverse the collected digits since they are generated in reverse order.\n6. If the number was negative, append a minus sign before returning the result.\n\n# Complexity\n- Time complexity:\nEach division reduces the number by a factor of 7, so the number of divisions is proportional to log7(n).  Therefore, the time complexity is O(log7(n)).\n\n- Space complexity:\nSince the string result stores the base 7 representation, the space complexity is O(log7(n)) because that\u2019s the maximum number of digits needed to represent the number in base 7.\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    string convertToBase7(int num) {\n    if (num==0) return "0";\n    bool isNegative = num<0;\n    num = abs(num);\n    string result = "";\n    \n    while(num>0){\n        int remainder = num % 7;\n        result += to_string(remainder);\n        num /= 7;\n    }\n    \n    if (isNegative) result += \'-\';\n    reverse(result.begin(), result.end());\n    return result;\n    }\n};\n```
['C++']