PracHub
QuestionsCoachesLearningGuidesInterview Prep

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.

  • medium
  • Hudson River Trading
  • Coding & Algorithms
  • Software Engineer

Count Length-3 Chat Substrings with a Vowel

Company: Hudson River Trading

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: trading - 网上海投 - 在线笔试

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.

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

  1. Scan each window of length 3.
  2. Uppercase vowels count too.
  3. Strings shorter than 3 have no valid substrings.
Last updated: Jul 2, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Count Digit-Reversal Equivalent Pairs - Hudson River Trading (medium)
  • Simulate Alternating Stick Collection for a Nest - Hudson River Trading (medium)
  • Calculate Completion Time for a Single-Server Reactor Queue - Hudson River Trading (medium)
  • Test easy–medium array/string tasks - Hudson River Trading (Medium)
  • Approach verbose data-structure design - Hudson River Trading (Medium)