you give sequence n digit d_1d_2 dot d_n you need paint digit colors digit paint color 1 color 2 write row leave right digit paint color 1 digit paint color 2 result sequence n digit nondecrease digit great equal previous digit for example sequence d914 valid color 211 paint color 1 digit paint color 2 digit but 122 valid coloring 9 concatenate 14 nondecrease sequenceit allow color Digits paint color require consecutive positionsfind valid way paint give sequence digit determine impossible