My solutions and proposals for strings #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @conanbatt
First case: I implemented three approaches (I'm learning Typescript so I took the opportunity to experiment). I used a different approach for non-additional-datastructure requirement. Instead of running linear, I sort the string so I can fix it with O(nlog(n)) complexity. I provide other two solutions (one with extra data structure and TS, and other with pure JS). I'm an old Java guy, so I'm trying to move to javascript and force myself to learn it to improve my skills.
Second scenario: I made it with a different approach, I guess it can be a little more complicated (I use a Set and a hash instead of two hashes) but I avoid traversing all the second hash again to check that it's 0 in all keys. In addition, I added a new test case to check if someone forgot to validate set/hashmap at the end. It can lead to false positives without this check.
I added a different approach for solving exercise 3 -with an array and replacing it in place, trying to use the original idea of mutable structure-. I hope it help to expand the combination of solutions.
All the other exercises are done with my approach trying to achieve the minimum time complexity.