Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update strComp.js #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update strComp.js #47

wants to merge 1 commit into from

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.

None yet

2 participants