-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution3264.go
More file actions
33 lines (29 loc) · 886 Bytes
/
solution3264.go
File metadata and controls
33 lines (29 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package solution3264
// ============================================================================
// 3264. Final Array State After K Multiplication Operations I
// URL: https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/
// ============================================================================
/*
goos: linux
goarch: amd64
pkg: GoLeetCode/solutions/3264---Final-Array-State-After-K-Multiplication-Operations-I
cpu: 13th Gen Intel(R) Core(TM) i7-13700K
BenchmarkGetFinalState
BenchmarkGetFinalState-24 41993293 28.47 ns/op 0 B/op 0 allocs/op
PASS
*/
func getFinalState(nums []int, k int, multiplier int) []int {
var idx, m int
for i := 0; i < k; i++ {
idx = 0
m = 1<<63 - 1
for j, v := range nums {
if v < m {
m = v
idx = j
}
}
nums[idx] = nums[idx] * multiplier
}
return nums
}