leetcode942】的更多相关文章

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…
给定只含 "I"(增大)或 "D"(减小)的字符串 S ,令 N = S.length. 返回 [0, 1, ..., N] 的任意排列 A 使得对于所有 i = 0, ..., N-1,都有: 如果 S[i] == "I",那么 A[i] < A[i+1] 如果 S[i] == "D",那么 A[i] > A[i+1] 示例 1: 输出:"IDID" 输出:[0,4,1,3,2] 示例 2:…