Skip to content

Commit ff8a03a

Browse files
committed
Runtime: 3027 ms (Top 7.32%) | Memory: 13.9 MB (Top 97.56%)
1 parent b25097e commit ff8a03a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/algorithms/L/Least Operators to Express Number/Least Operators to Express Number.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
# Runtime: 3027 ms (Top 7.32%) | Memory: 13.9 MB (Top 97.56%)
12
class Solution(object):
23
def leastOpsExpressTarget(self, x, target):
34
return self.cost(x, target)
4-
5+
56
def cost(self, x, val):
67
if val == x:
78
return 0
@@ -22,4 +23,4 @@ def cost(self, x, val):
2223
# x**(p+1) - val < val - x**p
2324
return min(p + self.cost(x, val - a), p + 1 + self.cost(x, b - val))
2425
else:
25-
return p + self.cost(x, val - a)
26+
return p + self.cost(x, val - a)

0 commit comments

Comments
 (0)