Given an integer `num`, return _a string of its **base 7** representation_.

**Example 1:**

**Input:** num = 100
**Output:** "202"

**Example 2:**

**Input:** num = -7
**Output:** "-10"

**Constraints:**

*   `-107 <= num <= 107`
```python
def convert_to_base7(num: int) -> str:
    if num == 0:
        return "0"
    result = ""
    negative = num < 0
    if negative:
        num *= -1
    while num > 0:
        result = str(num % 7) + result
        num //= 7
    return "-" + result if negative else result
```
explanation
The algorithm first checks if the input number is 0, and if so, it simply returns the base-7 representation as "0". If the number is negative, it keeps track of the sign and converts the number to positive. Then, it iteratively divides the number by 7 (integer division) and prepends the remainder (modulus) to the result string. Finally, if the input number was negative, it adds the minus sign back to the result string. The same algorithm is implemented in C++, Java, Python, and JavaScript with minor syntax adjustments.