← Atlassian Interview Insights

Atlassian·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Atlassian software engineer interview with a coding question that's basically a variant of LeetCode 68. Not the hardest problem in the world but the follow-up tripped me up a bit.

Questions Asked (1)

Q1

Given an array of words and a max line width, format the words into lines by packing as many words as possible per line and separating them with '-' characters. For lines with multiple words, distribute extra '-' evenly to fill the line width (full justification). The last line is left-justified with no extra padding, and a single-word line gets no extra '-'. Follow-up: what if you need to pad extra '-' on a justified line when there are remaining spaces?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I recognized the LeetCode 68 shape pretty fast, which helped, but swapping spaces for '-' as the separator threw me off more than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints and edge cases, then outline a greedy line-packing algorithm with careful handling of space distribution. For the follow-up, explain how to distribute remaining spaces when extra padding is needed, ensuring even distribution and proper handling of the last line and single-word lines.

Pro tip: Demonstrate awareness of real-world text justification by mentioning that the greedy approach is optimal for this problem, and discuss how the follow-up relates to the classic 'Text Justification' problem, showing you can connect to known algorithms.

1. Clarify requirements and edge cases

Ask about input constraints (e.g., word length vs. max width, empty array, single word), and confirm the rules for last line and single-word lines. Clarify the follow-up: when there are remaining spaces after even distribution, where should extra hyphens go?

2. Design greedy line packing

Iterate through words, adding to current line if it fits with at least one hyphen between words. When the next word doesn't fit, finalize the line and start a new one.

3. Justify lines (except last)

For each line except the last, compute total hyphens needed to reach max width. Distribute evenly among gaps; if remainder exists, add one extra hyphen to the leftmost gaps (or as specified). Handle single-word lines by left-justifying with no extra hyphens.

4. Handle last line and output

For the last line, join words with single hyphens and left-justify (no extra padding). Collect all lines into the final result.

5. Address follow-up on extra padding

Explain that when distributing extra hyphens, if there are more spaces than gaps, you can either add multiple hyphens per gap or, if the problem allows, add extra hyphens to the rightmost gaps. Clarify with the interviewer which convention to follow.

Key Points to Mention

  • Greedy algorithm for line packing: always fit as many words as possible.
  • Space distribution: even distribution with remainder handling (e.g., leftmost gaps get extra).
  • Edge cases: last line, single-word line, empty input, word longer than max width.
  • Time and space complexity: O(n) time where n is total characters, O(n) space for output.
  • Follow-up: when extra padding is needed, decide on distribution strategy (e.g., round-robin or left-biased).
  • Connection to classic 'Text Justification' problem and potential optimizations.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.