-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution1313.go
More file actions
28 lines (23 loc) · 766 Bytes
/
solution1313.go
File metadata and controls
28 lines (23 loc) · 766 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
package solution1313
// ============================================================================
// 1313. Decompress Run-Length Encoded List
// URL: https://leetcode.com/problems/decompress-run-length-encoded-list/
// ============================================================================
/*
$ go test -bench=. -benchmem
goos: linux
goarch: amd64
pkg: GoLeetCode/solutions/1313---Decompress-Run-Length-Encoded-List
cpu: 13th Gen Intel(R) Core(TM) i7-13700K
Benchmark_decompress-24 29512189 45.21 ns/op 56 B/op 3 allocs/op
PASS
*/
func decompressRLElist(nums []int) []int {
ans := make([]int, 0)
for i := 0; i < len(nums); i += 2 {
for j := 0; j < nums[i]; j++ {
ans = append(ans, nums[i+1])
}
}
return ans
}