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.