Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 415192e

Browse files
committed
964 accepted. 4ms, beats 14.29%
1 parent 6f8568c commit 415192e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Algorithms/0964.least-operators-to-express-number/least-operators-to-express-number.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ func helper(x, target, count int, res *int) {
4848
}
4949

5050
intRoot = max(intRoot, 1)
51-
if target-base <= base*x-target {
52-
helper(x, target-base, count+intRoot, res)
53-
helper(x, base*x-target, count+intRoot+1, res)
54-
} else {
51+
52+
helper(x, target-base, count+intRoot, res)
53+
if base*x-target < target {
5554
helper(x, base*x-target, count+intRoot+1, res)
56-
helper(x, target-base, count+intRoot, res)
5755
}
5856
}
5957

0 commit comments

Comments
 (0)