660. Remove 9 ¶ Time: $O(1)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6 7 8 9 10 11class Solution { public: int newInteger(int n) { string ans; while (n > 0) { ans = to_string(n % 9) + ans; n /= 9; } return stoi(ans); } }; 1 2 3 4 5class Solution { public int newInteger(int n) { return Integer.parseInt(Integer.toString(n, 9)); } } 1 2 3 4 5 6 7class Solution: def newInteger(self, n: int) -> int: ans = [] while n: ans.append(str(n % 9)) n //= 9 return ''.join(reversed(ans))