Leetcode Note: Go - Decompress Run Length Encoded List

Decompress Run-Length Encoded List - LeetCode
https://leetcode.com/problems/decompress-run-length-encoded-list/

  • Go 言語で取り組んだメモ

回答

Go simple - Decompress Run-Length Encoded List - LeetCode
https://leetcode.com/problems/decompress-run-length-encoded-list/solutions/2481607/go-simple/?orderBy=most_votes&languageTags=golang

func decompressRLElist(nums []int) []int {
    var res []int
    
    for i := 0; i < len(nums); i += 2 {
        for count := 0; count < nums[i]; count++ {
            res = append(res, nums[i+1])
        }
    }
    
    return res
}