class Solution {

public:

```
char help(int n) {
assert(n >= 0 && n <= 15);
if (n <= 9) return '0' + n;
return 'a' + (n - 10);
}
string transform(unsigned n) {
string ans = n >= 16 ? transform(n / 16) : "";
ans.push_back(help(n % 16));
return ans;
}
string toHex(int num) {
unsigned input = num;
return transform(input);
}
```

};