Reported May 2026
Airbnbsimulation

Print Sentences as Table

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

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

You're looking at an Airbnb OA from May 2026 that asks you to format sentences into a bordered table. This is a string manipulation and formatting problem, not an algorithm challenge. The trick is getting the border and padding logic right in one pass. You need to read n and width, then for each sentence output a border line, the sentence padded to width, another border line. StealthCoder will catch the off-by-one errors in your padding or border construction if you freeze up on the live assessment.

The problem

Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem. You are given n sentences and a fixed table content width width. Print each sentence as one row in a bordered table. Input The first line contains two integers n and width. The next n lines each contain one sentence. Sentences may contain spaces, and each sentence length is guaranteed to be at most width. Output For each sentence, output a border line, then the sentence row, then continue with the next border line. A border line is +, followed by width + 2 dash characters, followed by +. A sentence row starts with |, then the sentence, then enough trailing spaces to fill exactly width content characters, then |. If n = 0, return no output lines. Example Input: 3 55, followed by Hello world, How are you today, and Bye. The sample output is shown in the visible example. Function Description Complete solvePrintSentencesAsTable. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters. The returned string array must match the expected standard output lines for the sample input.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The problem is pure formatting. Read n and width from the first line. For each of the n sentences, output three things in order: a top border (+ followed by width+2 dashes then +), the sentence row (| plus the sentence plus trailing spaces to reach exactly width characters plus |), then repeat. The edge case is n=0, which returns an empty array. Most candidates botch the padding calculation or forget that each sentence needs its own top and bottom border. The pattern is simulation, not dynamic programming or search. If you trace through the example (n=3, width=55), you'll see the rhythm: border, row, border, row, border, row, border. Write it iteratively and test your string concatenation carefully before submission.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Print Sentences as Table 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder
⏵ The honest play

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

Airbnb reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Print Sentences as Table FAQ

Do I need to output a final border after the last sentence?+

Yes. The structure is border-row-border-row-border. So after the last sentence, you output one final border. This trips up candidates who think they're done after the last row.

How do I handle the padding if the sentence is shorter than width?+

Add trailing spaces so the content between the two | characters is exactly width characters long. If the sentence is 10 characters and width is 55, add 45 spaces. The | characters sit outside that count.

What if n is 0?+

Return an empty array, no lines at all. This is the only edge case worth checking before submission.

Is the border line always + plus (width+2) dashes plus +?+

Yes, always. So if width is 55, the border is + followed by 57 dashes followed by +. That's 59 characters total per border line.

How much time should this take during the OA?+

5-10 minutes if you trace through the example carefully. The logic is straightforward. Most failures come from rushing the padding or border arithmetic, not from algorithmic complexity.

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

OA at Airbnb?
Invisible during screen share
Get it