Pad with asterisks
Input
s='hello', length=10, pad_char='*'
Output
**hello***
Original length 5, target 10 => need 5 pads; distribute 2 on left and 3 on right.
Full lesson preview
Trim a string if it's too long and center-pad it if it's too short, using a specified pad character.
Problem statement
Task
Examples
Input
s='hello', length=10, pad_char='*'
Output
**hello***
Original length 5, target 10 => need 5 pads; distribute 2 on left and 3 on right.
Input format
Output format
Constraints
Samples
Input
s='longstring', length=4
Output
long
Truncate to the first 4 characters.