Skip to content

Conversation

@AmitJoki
Copy link

No description provided.

Copy link
Collaborator

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was this change fixing? 🤔

@AmitJoki
Copy link
Author

It is a simpler implementation and which is more easier to read in my opinion.

Copy link
Collaborator

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I didn't get time to to debug the code, but could you please fix it, I find some test cases failing, e.g.

compress('abbbbc') // abbbbc
compress('abbbcc') // abbbcc
compress('abbbccc') // a1b3c3 --> a1 should just be 'a'

@AmitJoki
Copy link
Author

AmitJoki commented Aug 26, 2019

The one in the original code counts a single character as 1.

console.log('aabcccccaaa', compress('aabcccccaaa'), 'a2b1c5a3');

As you can see b1 is present in the original code.

As far as other test cases,abbbbc would become a1b4c1 which is the same length as the original and hence the original is returned. So is the case for a1b3c2 as the length is same as that of original in which case the original is returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants