you give 0indexed string pattern length n consist character I mean increase d mean decreasinga 0indexed string num length n 1 create follow conditionsnum consist digit 1 9 digit onceif patterni I numi numi 1if patterni D numi numi 1Return lexicographically smallest possible string num meet condition Example 1input pattern IIIDIDDDOutput 123549876explanationat index 0 1 2 4 numi numi1At index 3 5 6 7 numi numi1some possible value num 245639871 135749862 123849765it prove 123549876 small possible num meet conditionsnote 123414321 possible digit 1 onceExample 2input pattern DDDOutput 4321explanationsome possible value num 9876 7321 8742it prove 4321 small possible num meet condition Constraints1 patternlength 8pattern consist letter I d