题目:
题解:
func minMoves(nums []int) (ans int) {
min := nums[0]
for _, num := range nums[1:] {
if num < min {
min = num
}
}
for _, num := range nums {
ans += num - min
}
return
}
题目:
题解:
func minMoves(nums []int) (ans int) {
min := nums[0]
for _, num := range nums[1:] {
if num < min {
min = num
}
}
for _, num := range nums {
ans += num - min
}
return
}