C# solution(beats 99%) needs extra space


  • 0
    D
    public class Solution {
        public IList<int> FindDisappearedNumbers(int[] nums) {
            List<int> count = new List<int>();
            int[] temp = new int[nums.Length];
            foreach(int t in nums)
            {
                temp[t-1]=1;
            }
            for(int i=0;i<nums.Length;i++)
            {
                if(temp[i]!=1)
                {
                count.Add(i+1);
                }
            }
            return count;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.