Count Length-3 Chat Substrings with a Vowel
Company: Hudson River Trading
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: trading - 网上海投 - 在线笔试
Quick Answer: This Hudson River Trading coding question checks careful string scanning over fixed-length substrings with a small character predicate. It is a compact console-ready exercise for practicing boundary handling, linear traversal, and turning a short interview prompt into reliable code.
Constraints
- 0 <= chatMessage.length <= 100000
- chatMessage contains English letters.
Examples
Input: ("codeSignal",)
Expected Output: 8
Explanation: Every length-3 window contains a vowel.
Input: ("StrEngThen",)
Expected Output: 5
Explanation: Five of the eight windows contain a vowel.
Input: ("",)
Expected Output: 0
Input: ("ab",)
Expected Output: 0
Input: ("bcdf",)
Expected Output: 0
Input: ("aaa",)
Expected Output: 1
Input: ("ABC",)
Expected Output: 1
Input: ("bcAxyz",)
Expected Output: 3
Input: ("rhythm",)
Expected Output: 0
Hints
- Scan each window of length 3.
- Uppercase vowels count too.
- Strings shorter than 3 have no valid substrings.