Hi there!
Beginner to leetcode, I've been able to work through a handful of algorithms with no hiccups, but I'm getting hung up on this one. It seems like every time I run code, no matter what the intended output should be, it is always coming up as an empty array []. This is true for both run code and submit. Here is my solution for reference:
var compress = function(chars) {
let arr = []
let count = 1
for (let i = 0; i < chars.length; i++) {
if (chars[i] === chars[i+1]) {
count++
} else {
arr.push(chars[i], count)
count = 1
}
}
return arr
};I've also tried this and had the same result:
var compress = function(chars) {
return 'PLEASE RETURN THIS'
};Is this user error or a bug? What can I do to get my answer through?
Any help is greatly appreciated.