DI String Match Problem

DI String Match Problem — ExecCode Easy DSA Practice

Solve the DI String Match problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a string s, reconstruct the permutation perm and return it. Your task is to if there are multiple valid permutations perm, return any of them. 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].

Examples

Input {"s": "IDID"}; Output [0, 4, 1, 3, 2]. Input {"s": "III"}; Output [0, 1, 2, 3]

Constraints

1 <= s.length <= 10^5 s[i] is either 'I' or 'D'.

Practice DI String Match free on ExecCode. Browse DSA problems, topic map, and placement guides.