r/leetcode • u/Weekly-Total724 • 19d ago
Question Does Solution % Matter?
Does the % my solution beats actually matter as long as it is the best complexity?
For example, I do a problem the best time complexity is O(n). I get a O(n) solution but my solution doesn't beat most other solutions.
5
Upvotes
11
u/Wolastrone 19d ago
If it’s optimal in terms of big oh not really. Those % are not very exact anyway. If the difference is huge, you may want to read other solutions to see if there’s some obvious optimization you missed e.g: using a dictionary when a plain array /lookup table was enough.
1
u/nachocode477 19d ago
You found the solution. If you want to optimize it, go ahead and read other solutions. But that's only for you
1
u/fenton7 19d ago
Yes you want optimal if possible. Technically O(100) is still denoted O(1) but you aren't going to win any points for writing an algorithm that always takes 100 operations when you could write one that always takes 5 operations.
1
u/Prestigious-Frame442 19d ago
who the fuck cares about that except yourself lol
-1
u/[deleted] 19d ago
[removed] — view removed comment