You are given a string s made of characters 'I' and 'D'.
'I' means the next number should be greater than the current number.
'D' means the next number should be smaller than the current number.
You need to create a permutation (an ordering) of numbers from 0 to n (where n is the length of s) which follows this rule throughout the string.
If multiple such permutations are possible, you may return any one of them.
Input: s = "IIID"
Output: [0,1,2,3,1]
Explanation:
First 3 positions increase, last decreases.
Input: s = "DID"
Output: [3,1,2,0]
Explanation:
D → 3 > 1 I → 1 < 2 D → 2 > 0
Input: s = "DDDD"
Output: [4,3,2,1,0]
Explanation:
Each step must decrease.
Accepted:
Submission: