Ad
  • Default User Avatar

    It would not make it O(n^2). It would still be O(n) because it's looping through the vowels (a constant known length) for each char in the input, and we're still only looping through the input once. The constant in this case would be at least 5, though, so it would run in approximately 5n time.

  • Custom User Avatar

    Yes, it has to scan each element in the array each time it's called. include? always returns a boolean value. if true do what's in the code block, in this case increase the count by 1.

  • Custom User Avatar

    How does include work?
    Does it loop through the array each time its called?
    Wouldn't that make it n**2?

  • Custom User Avatar

    good to know you can splip up the elements of an array like that.