Simplero | OA | Format String With dashes
Anonymous User
233

Software Engineer - Remote

Get numbers from the given string, and format them following the rules below:

  1. When possible the numbers should always be 3 digits long:
input: "a1bc23456"
output : "123-456"
  1. Digits can never be 1, so if happens to be 1, it should have sets of 2 at the end
input: "a1bc234"
output : "12-34"
input: "a1bc23defg4567"
output : "123-45-67"

If there is a similar question on leetcode, please feel free to post it below.

Comments (2)