Given a string diString
that only contains "I"
(increase) or "D"
(decrease), let N = S.length.
Return any permutation Array of [0, 1, ..., N] such that for all Index = 0, ..., N-1:
If S[i] == "I", then A[i] < A[i+1]
If S[i] == "D", then A[i] > A[i+1]
1 <= diString
.length <= 10000 , diString
only contains characters "I"
or "D"
.
Example 1:
Input: "ID"
Output: [ 0, 2, 1 ]
Example 2:
Input: "DID"
Output: [ 3, 0, 2, 1 ]
Example 3:
Input: "DIDIID"
Output: [ 6, 0, 5, 1, 2, 4, 3 ]
starter code
const diStringPermutation = diString => {
}
using your logic what you will write to change his mind ?
Hint: use let ?