Answers and Comments


User Avatar
Written by deeringc


You should use greedy approach:

Position 0: cannot be zerro, so we put "1"
Position 1: cannot be zerror as we have one "1", cannot be "1" or we would violate the condition by having two "1"s, so we choose "2"
Position 2: cannot be zerro as we have one "2", so put "1"
Position 3: can be zerro

So, minimal number is 1210

Maximum number is infinity


User Avatar
Written by Kursant


There are not so many possible combinations:

n=1: no solution
n=2: no solution
n=3: no solution
n=4: 1210, 2020
n=5: 21200
n=6: no solution
n=7: 3211000
n=8: 42101000
n=9: 521001000
n=10: 6210001000


Saved Stories

Sponsored Categories