Reported September 2026
Faireprefix sum

Find the First Contiguous Haiku

Reported by candidates from Faire's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Faire OA. Under 2s to a working solution.
Founder's read

Faire reported this one in September 2026, and the title sounds fancier than the problem is. It looks like a poetry puzzle, but it reduces to a running syllable sum over tokens. For each starting index, you walk forward and check if the cumulative total hits 5, then 12, then 17 exactly. The real work is the token cleanup: lowercase, strip edge punctuation, keep internal apostrophes. If you blank on the parsing details during the live OA, StealthCoder is the invisible safety net that reads the problem and hands you a working solution.

The problem

Given a sentence, a dictionary of normalized words, and their positive syllable counts, return the first contiguous segment that forms a 5-7-5 haiku.
Split the sentence on ASCII whitespace. For dictionary lookup, lowercase each token and strip surrounding punctuation while preserving internal apostrophes. Return three strings made from the original tokens, preserving spelling and punctuation. Choose the smallest starting token index whose cumulative syllable boundaries are exactly 5, 12, and 17. Return an empty array when no such segment exists.

Function
findFirstHaiku(sentence: String, words: String[], syllables: int[]) → String[]

Examples
Example 1
sentence = "Noise, a quiet old pond a frog jumps in sound again."
words = ["noise","a","quiet","old","pond","frog","jumps","in","sound","again"]
syllables = [2,1,2,1,1,1,1,1,1,2]
return = []
This input does not reach a final five-syllable line, so no complete haiku exists and the returned array is empty.
Example 2
sentence = "Bright sun over hills soft rain touches green leaves calm winds carry birds home"
words = ["bright","sun","over","hills","soft","rain","touches","green","leaves","calm","winds","carry","birds","home"]
syllables = [1,1,2,1,1,1,2,1,1,1,1,2,1,1]
return = ["Bright sun over hills","soft rain touches green leaves calm","winds carry birds home"]
The three consecutive groups total 5, 7, and 5 syllables.

Constraints
1 <= token count <= 2000
words.length == syllables.length
Every normalized sentence token appears exactly once in words.
Every syllable count is positive.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is prefix sums over syllable counts. Build a map from normalized word to syllables, normalize each token, and compute prefix sums. A haiku starting at index i exists if prefix[i]+5, prefix[i]+12 and prefix[i]+17 all appear as boundaries. Since syllables are positive, prefix sums strictly increase, so a hash set or a two-pointer walk finds them fast. With at most 2000 tokens, even the brute-force scan from each start is fine. Pitfalls: stripping internal apostrophes by accident, returning normalized text instead of original tokens, and joining lines with the wrong separator. Lines are the original tokens joined by single spaces. Take the smallest start index and return as soon as you find one. Note example 1 has no valid segment, so return an empty array. If the normalization rules trip you up under pressure, StealthCoder is your hedge on the live OA.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Find the First Contiguous Haiku cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder
⏵ The honest play

You've seen the question. Make sure you actually pass Faire's OA.

Faire reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find the First Contiguous Haiku FAQ

What's the trick in the Faire haiku problem?+

Prefix sums. Convert each token to its syllable count, build cumulative totals, then for each start check whether start+5, start+12 and start+17 are exact boundaries. Because every count is positive, the sums only increase, so lookups are clean and unambiguous.

How hard is this problem really?+

Easy to medium. The algorithm is simple, but the normalization rules cause most bugs. Lowercase, strip surrounding punctuation only, keep internal apostrophes like in contractions. Get that right and the rest is a short loop.

Do I return the normalized words or the original tokens?+

Original tokens, with their spelling and punctuation intact. Normalize only for the dictionary lookup. Each of the three strings is the original tokens for that line joined by single spaces, as in the second example.

Is brute force acceptable with 2000 tokens?+

Yes. Trying every start and scanning up to 17 syllables forward is at most about 17 tokens per start, since each token has at least one syllable. That's effectively linear. A prefix-sum set is cleaner, but brute force passes.

How do I prepare for this in 48 hours?+

Practice prefix sums and string normalization on small inputs. Hand-trace both examples, including the empty-array case. Write the normalize helper first and test it on tokens with commas, periods and apostrophes, since that's where wrong answers come from.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Faire.

OA at Faire?
Invisible during screen share
Get it