So I wrote the code that I thought was a good one, then I checked the website's solution.
Is my code flawed in some way? asking out of curiosity.
My code:
Website solution:
Is my code bad vs standard solution
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
13 October 2022, 14:02
it passed, why would you think your solution is flawed. I could google this problem and come up with a different solution online or I could create my own solution that would be different than any before. What metric do you consider to make one code better than the next: It runs fastest, it uses the least memory, its easy to read, something else?
What I like about the websites code:
It is easy to read. I can look at the code and figure out what it does without having to run it. Your code, while similar, doesn't use descriptive variables so it is hard to determine what it does without running it a few times.
What I like about your code:
Your entire solution class is only 20 lines. You solved the problem with a much more compact algorithm.
0