Product
Pricing
Blog
Forum
NEW
Referral
Description
Solution
Discussion
Submissions
Ask AI
AI Insights
Quick Summary
Pack words greedily onto each line until adding another would exceed the specified width.
Pad each completed line to exactly the target width using trailing spaces for LEFT alignment or leading spaces for RIGHT alignment.
Wrap every formatted content row in a single asterisk on each side, bordered above and below by full-width asterisk rows.
What This Tests
Greedy line-packing logic
String manipulation and padding
Array traversal and state tracking
Boundary condition handling
Output formatting under constraints
Common Patterns
Greedy
Collapse
Hint 1
Hint 2
What Interviewers May Ask Next
Report
Report seen similar question in interview
Ask AI Assistant
Ask AI Assistant
Ask me anything about this coding question!
python
Auto
Debug
Run
Submit
Test Cases
Input
Output
Expected