|
|
|
|
|
by globular-toast
1606 days ago
|
|
You're not the only one, but it's the equivalent of walking round a foreign country with a phrasebook versus being fluent in the native language. In this case, for example, you seem unaware that reduce is just doing a funny thing with a loop and won't be faster, but you've been seduced by shorter looking code because it looks more clever. There is, in fact, value in the reduce method but it's nothing to do with speed or efficiency (it's because it's declarative). But if this were Python, and the reduce was a call to numpy, then it would be about speed and efficiency. The point of doing stuff like leetcode is (or should be) to test real understanding of the technology, not an ability to copy/paste from StackOverflow. |
|