Beginner's logic ( 0 ms)
IntuitionApproachJust convert num mod 7 to string and append it to the first place by using the '+', then check if negative then append '-'. Remember that u hav
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->
Just convert num mod 7 to string and append it to the first place by using the '+', then check if negative then append '-'. Remember that u have to make the num positive or else it will append a lot of negative sign. That simple :>
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
string convertToBase7(int num) {
    if (num == 0) return "0";
    string result;
    bool isNegative = (num < 0);
    num = abs(num);
    while (num > 0) {
        result = to_string(num % 7) + result;
        num /= 7;
    }
    return (isNegative)? '-' + result : result;
}
};
```
['C++']