Quick Overview

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.

Count Length-3 Chat Substrings with a Vowel

Company: Hudson River Trading

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are developing an automatic moderation system for a chat application that detects simple linguistic patterns. Given a string `chatMessage`, count how many substrings of exactly length `3` contain at least one vowel. Vowels are `a`, `e`, `i`, `o`, and `u`, and uppercase vowels should count as vowels too. Return the count as an integer. Example 1: ```text chatMessage = "codeSignal" output = 8 ``` The length-3 substrings are `cod`, `ode`, `des`, `esi`, `sig`, `ign`, `gna`, and `nal`; each contains at least one vowel. Example 2: ```text chatMessage = "StrEngThen" output = 5 ``` Among the eight length-3 substrings, five contain at least one vowel. Constraints: - `0 <= chatMessage.length <= 100000` - `chatMessage` contains English letters. - A solution with worse than linear time is acceptable for small inputs, but aim for a simple linear scan.

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.

Given a string chatMessage, count substrings of exactly length 3 that contain at least one vowel. Vowels are a, e, i, o, u and uppercase variants.

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.

Hints

  1. Scan each window of length 3.
  2. Uppercase vowels count too.
  3. Strings shorter than 3 have no valid substrings.

Loading coding console...