CtCI-6th-Edition-JavaScript-ES2015 icon indicating copy to clipboard operation
CtCI-6th-Edition-JavaScript-ES2015 copied to clipboard

Alternate solutions to problems

Open joshuazmiller opened this issue 8 years ago • 1 comments

I'm starting to write some alternate solutions to these problems. Some of the proposed solutions appear more concise and possibly perform better. Please consider including them. Thanks.

joshuazmiller avatar Aug 13 '16 18:08 joshuazmiller

@joshuazmiller thank you for the contribution.

Please run the linting and test tools as described in the README. There are a few linting issues the most significant of which is that you don't export your added functions and as such they are not tested by the existing tests.

I also disagree with the stated time complexity of the two solutions you've provided. The asymptotic running time for q1 is O(N^2) and q2 is O(N*M) due to your usage of both string.indexOf and string.splice. As such both algorithms are going to be much slower than the other solutions on very large inputs.

diadical avatar Aug 22 '16 04:08 diadical