public class Solution {
    public IList<int> FindDisappearedNumbers(int[] nums) {
        Dictionary<int, int> dic = new Dictionary<int, int>();
            for (int i = 1; i <= nums.Length; i++)
            {
                dic.Add(i, 0);
            }

            for (int i = 0; i < nums.Length; i++)
            {
                dic[nums[i]]++;
            }

            var list = new List<int>();
            for (int i = 1; i <= nums.Length; i++)
            {
                if (dic[i] == 0)
                {
                    list.Add(i);
                }
            }

            return list;
    }
}

https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/#/description

posted on 2017-04-19 10:58  Sempron2800+  阅读(134)  评论(0编辑  收藏  举报