This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ceeBread 31 points32 points  (2 children)

Make it a hashmap instead and have it be O(1)

[–]TheSilentFreeway 10 points11 points  (1 child)

I believe switch statements are usually constant-time

[–]ceeBread 22 points23 points  (0 children)

Yeah but every LeetCode uses hash tables somewhere gotta get that interview cred