public class Solution {
public int[] DecompressRLElist(int[] nums) {
var list = new List<int>();
for (var i = 0; i < nums.Length; i += 2) {
var count = nums[i];
var toDup = nums[i + 1];
while (count-- > 0) {
list.Add(toDup);
}
}
return list.ToArray();
}
}
Source: https://leetcode.com/problems/decompress-run-length-encoded-list/
"Simplicity can't be bought later, it must be earned from the start" -- DB
Monday, February 15, 2021
Leetcode Everyday: 1313. Decompress Run-Length Encoded List. Easy
Labels:
leetcode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment