0942. DI String Match
https://leetcode.com/problems/di-string-match
Description
A permutation perm
of n + 1
integers of all the integers in the range [0, n]
can be represented as a string s
of length n
where:
s[i] == 'I'
ifperm[i] < perm[i + 1]
, ands[i] == 'D'
ifperm[i] > perm[i + 1]
.
Given a string s
, reconstruct the permutation perm
and return it. If there are multiple valid permutations perm, return any of them.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= s.length <= 105
s[i]
is either'I'
or'D'
.
ac
Last updated