Comment

Comment by F-0X

> And it hit me that it's actually O(n), because we've got an array and have to iterate over every element to see if the element matches char.

No, it's actually O(1). n refers to the _input_, which is always a single character. The iteration over an array (fixed at 5 elements) means a maximum of 5 comparisons. O(isVowel) = 5.

parent F-0X 6 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton