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