public class Solution
    {
        public int[] DiStringMatch(string S)
        {
            var len = S.Length;
            var min = 0;
            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 list.ToArray();
        }
    }

 

posted on 2018-11-18 18:49  Sempron2800+  阅读(152)  评论(0编辑  收藏  举报