Search
⌘K

Leetcode 1694. Reformat Phone Number

Remove non-digit characters from the input string and then split the digits into groups of three from left to right, adjusting the final groups so there are no single-digit blocks (if 4 digits remain split into two 2's; if 3 or 2 remain keep them as one block). Join the groups with dashes and return the result.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.