r1cc4rdo / daily_coding_problem

Solutions to https://dailycodingproblem.com
The Unlicense
160 stars 39 forks source link

modify coding_problem_17:using a tree structure #3

Closed Jedshady closed 6 years ago

Jedshady commented 6 years ago

Hey mate, Run through this problem 17. I found yours is way simple and can easily fail if test case varies. I think this problem has to engage a tree structure. So I'm sharing my solution. Hopefully it is correct, but still not fully tested. Need further effort. Cheers, Kye

r1cc4rdo commented 6 years ago

Hey buddy :)

thanks for the code -- there were definitely more than a few problems with my solution. I updated my own code, which now passes your longer example and a few new tests.

I checked yours, and feel like it's doing more than necessary. There is no need to create and then parse a large object structure for computing the longest path. Your solution is lengthier, has higher time/space complexity, and does not check for malformed paths. I'm striving here for minimalism, convince me on why should I pull ;)

I left a few more comments, mostly nitpicking, on your commit.

Jedshady commented 6 years ago

Hey Riccardo, I checked your modified code. It is genius. I never thought it would do the same using just a list. That's brilliant. I will try follow your thought and make it more robust. Thanks for sharing the code. Compared to yours, definitely mine is overkilled. No need to merge.