Package g0901_1000.s0942_di_string_match
Class Solution
- java.lang.Object
-
- g0901_1000.s0942_di_string_match.Solution
-
public class Solution extends Object
942 - DI String Match.Easy
A permutation
permofn + 1integers of all the integers in the range[0, n]can be represented as a stringsof lengthnwhere:s[i] == 'I'ifperm[i] < perm[i + 1], ands[i] == 'D'ifperm[i] > perm[i + 1].
Given a string
s, reconstruct the permutationpermand return it. If there are multiple valid permutations perm, return any of them.Example 1:
Input: s = “IDID”
Output: [0,4,1,3,2]
Example 2:
Input: s = “III”
Output: [0,1,2,3]
Example 3:
Input: s = “DDI”
Output: [3,2,0,1]
Constraints:
1 <= s.length <= 105s[i]is either'I'or'D'.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
-
-
Method Detail
-
diStringMatch
public int[] diStringMatch(String s)
-
-