Skip to content

Commit 35a1e9f

Browse files
authored
Create remove-9.cpp
1 parent caed758 commit 35a1e9f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

C++/remove-9.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Time: O(logn)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
int newInteger(int n) {
7+
int result = 0, base = 1;
8+
while (n > 0) {
9+
result += (n % 9) * base;
10+
n /= 9;
11+
base *= 10;
12+
}
13+
return result;
14+
}
15+
};

0 commit comments

Comments
 (0)