Yeah, swapping seems to be better, would keep the large digits in the lesser valuable positions.
I interpreted the rules this way, because it didn't seem right to lose a digit in the resulting number. That would be like assuming input set [1,2,0] as equivelent to [1,2].
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ruby:
Edit: Fixed the 0 edge case. Instead of adding 0 to the end of the number, put it in the 2. position.
Wouldn't rotating the array bring the biggest number at the front?
I think swapping the 1st and 2nd number would be ideal.
Also is having a leading zero really against the rules?
Yeah, swapping seems to be better, would keep the large digits in the lesser valuable positions.
I interpreted the rules this way, because it didn't seem right to lose a digit in the resulting number. That would be like assuming input set
[1,2,0]
as equivelent to[1,2]
.