Skip to content

Commit 55a1579

Browse files
committed
Runtime: 11 ms (Top 9.31%) | Memory: 5.9 MB (Top 81.51%)
1 parent fa462a1 commit 55a1579

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
// Runtime: 11 ms (Top 9.31%) | Memory: 5.9 MB (Top 81.51%)
12
class Solution {
23
public:
34
int integerReplacement(int n) {
4-
5+
56
return helper(n);
67
}
78

89
int helper(long n)
910
{
1011
if(n == 1)
1112
return 0;
12-
13+
1314
if(n % 2)
1415
return 1 + min(helper(n - 1), helper(n + 1));
15-
16+
1617
return 1 + helper(n / 2);
1718
}
18-
};
19+
};

0 commit comments

Comments
 (0)