You are given an array of integers nums and a string s. Compute the following five values and return them together as a list of integers in this exact order:
-
The sum of all elements in
nums
.
-
The maximum element in
nums
.
-
The minimum element in
nums
.
-
The number of vowels (a, e, i, o, u, case insensitive) in
s
.
-
The length of
s
.
Return the five values as [sum, max, min, vowel_count, length].
Function Signature
def warmup(nums: list[int], s: str) -> list[int]:
...
Rules
-
The vowels are
a
,
e
,
i
,
o
,
u
in either case. The letter
y
is not a vowel.
-
The length counts every character of
s
, including spaces and punctuation.
-
The sum is the exact integer sum. It can exceed the 32-bit range.
Constraints
-
1 <= len(nums) <= 10^4
-
-10^9 <= nums[i] <= 10^9
-
1 <= len(s) <= 10^4
-
s
consists of printable ASCII characters.
Examples
Input: nums = [1,2,3,4,5], s = "Hello"
Output: [15,5,1,2,5]
The sum is 15, the maximum is 5 and the minimum is 1. "Hello" has the vowels e and o, so the count is 2, and it has 5 characters.
Input: nums = [-3,-1,-7,2,0], s = "Programming"
Output: [-9,2,-7,3,11]
The sum is -3 - 1 - 7 + 2 + 0 = -9, the maximum is 2 and the minimum is -7. "Programming" has the vowels o, a and i, and it has 11 characters.
Input: nums = [1000000000,1000000000,1000000000], s = "AEIOU y!"
Output: [3000000000,1000000000,1000000000,5,8]
The sum is 3000000000, which is larger than the 32-bit signed maximum of 2147483647. The five uppercase letters are vowels, while the space, y and ! are not, and the string has 8 characters in total.