Skip to content

Commit

Permalink
Update 3sum-closest.md
Browse files Browse the repository at this point in the history
  • Loading branch information
silves-xiang authored Oct 16, 2022
1 parent 63a7d02 commit ff9351b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion algorithm/docs/3sum-closest.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func threeSumClosest(nums []int, target int) int {
r := len(nums) - 1
for l < r {
current := nums[i] + nums[l] + nums[r]
if math.Abs(float64(sum - current)) > math.Abs(float64(target - current)) {
if math.Abs(float64(sum - target)) > math.Abs(float64(target - current)) {
sum = current
}
if current < target {
Expand Down

0 comments on commit ff9351b

Please sign in to comment.