Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    942 - DI String Match.

    Easy

    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' if perm[i] < perm[i + 1], and

    • s[i] == 'D' if perm[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:

    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:

    • <code>1 <= s.length <= 10<sup>5</sup></code>

    • s[i] is either 'I' or 'D'.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final IntArray diStringMatch(String s)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait