Rewrite 1.6 to have clearer algorithm and fix bug#16
Rewrite 1.6 to have clearer algorithm and fix bug#16heytonytan wants to merge 1 commit intocareercup:masterfrom
Conversation
…ng is not returned in instance of compressed string being same length as original string.
|
@dawsbot did forced push in my repo to clean things up. Take a look and see if this makes sense. Your Travis CI is also failing. I think for purposes of this repo of coding interview questions, wondering if we could consider doing away with continuous integration as the files/functions are standalone :) |
dawsbot
left a comment
There was a problem hiding this comment.
I'm pretty confused at the complete change in logic. Why don't you keep the entire code the same, remove the maxCount logic, and then do the return like you have in the new code?
return answer.length < string.length ? answer : string; looks great
|
Hey @dawsbot, I wrote the previous version sometime back and thought that this rewrite presented the code much more cleanly with a parse-reduce approach. The logic is pretty much the same.. Thanks for taking the time! |
|
I figured I might be able to provide some insight here (I realize this is a very old PR). I was looking at this and the original answer actually doesn't work as expected and outlined in the question in the book. The change in logic in the return line fixes the problem. The compressed string algorithm in the original answer is using |
|
I don't maintain this anymore, sorry folks. Hopefully, you can find someone at @careercup 🙏 |
Current bug: original string is not returned in instance of compressed string being same length as original string.