Given a string S that only contains "I" (increase) or "D" (decrease), let N = S.length. Return any permutation A of [0, 1, ..., N] such that for all i = 0, ..., N-1: If S[i] == "I", then A[i] < A[i+1] If S[i] == "D&qu…
public class Solution { public int[] DiStringMatch(string S) { var len = S.Length; ; var max = len; var list = new List<int>(); foreach (var s in S) { if (s == 'D') { list.Add(max); max--; } else { list.Add(min); min++; } } list.Add(min++); return l…