PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Faire

Find first 5-7-5 haiku in sentence

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in string processing, tokenization, dictionary-based lookup for syllable counts, and algorithmic substring search with attention to time and space complexity.

  • Medium
  • Faire
  • Coding & Algorithms
  • Software Engineer

Find first 5-7-5 haiku in sentence

Company: Faire

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Given a sentence containing mixed case and punctuation, and a syllable dictionary mapping lowercase words to their syllable counts, implement find_haiku(sentence: str, syllable_dict: dict) -> list[str] | None that returns the first contiguous three-line haiku with 5, 7, and 5 syllables respectively. Treat tokens case-insensitively for dictionary lookups and strip leading/trailing punctuation when matching keys, but preserve the original tokens’ casing and punctuation when returning the three lines. The lines must be formed by partitioning a single contiguous subsequence of words into three consecutive segments that sum to 5, 7, and 5 syllables. If no such subsequence exists, return None. Aim for O(N) time (e.g., prefix sums + hashing) and state space complexity. Discuss edge cases such as unknown words, apostrophes (e.g., "don't"), trailing punctuation, and multiple spaces.

Quick Answer: This question evaluates proficiency in string processing, tokenization, dictionary-based lookup for syllable counts, and algorithmic substring search with attention to time and space complexity.

Related Interview Questions

  • Print a Centered Pascal Triangle - Faire (medium)
  • Format text into fixed-width justified lines - Faire (hard)
  • Find First Haiku in Sentence - Faire (Medium)
Faire logo
Faire
Jul 28, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
6
0

Given a sentence containing mixed case and punctuation, and a syllable dictionary mapping lowercase words to their syllable counts, implement find_haiku(sentence: str, syllable_dict: dict) -> list[str] | None that returns the first contiguous three-line haiku with 5, 7, and 5 syllables respectively. Treat tokens case-insensitively for dictionary lookups and strip leading/trailing punctuation when matching keys, but preserve the original tokens’ casing and punctuation when returning the three lines. The lines must be formed by partitioning a single contiguous subsequence of words into three consecutive segments that sum to 5, 7, and 5 syllables. If no such subsequence exists, return None. Aim for O(N) time (e.g., prefix sums + hashing) and state space complexity. Discuss edge cases such as unknown words, apostrophes (e.g., "don't"), trailing punctuation, and multiple spaces.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Faire•More Software Engineer•Faire Software Engineer•Faire Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ 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
  • Compare Platforms
  • Discord Community

Support

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

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.