Return the sum, max and min of an array plus the vowel count and length of a string

Quick Overview

Compute five values in one function: the sum, maximum and minimum of an integer array, and the vowel count and length of a string. This warmup tests single-pass aggregation, correct initialization of running extremes, case-insensitive matching and awareness of integer overflow.

Return the sum, max and min of an array plus the vowel count and length of a string

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

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 ```python 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 ```text 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. ```text 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. ```text 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.

Overview: Compute five values in one function: the sum, maximum and minimum of an integer array, and the vowel count and length of a string. This warmup tests single-pass aggregation, correct initialization of running extremes, case-insensitive matching and awareness of integer overflow.

General logo
General
Nov 25, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0

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.