Missing Numbers

  • + 1 comment

    correct me if i am wrong but it is possible with 100 size

    frequency array-

    class Solution

    { static void Main(String[] args) {

        int n = Convert.ToInt32(Console.ReadLine());
    
        String s1_temp = Console.ReadLine();
    
        int m = Convert.ToInt32(Console.ReadLine());
    
        String s2_temp = Console.ReadLine();
    
       int[] s1 = Array.ConvertAll(s1_temp.Split(' '), int.Parse);
    
       int[] s2 = Array.ConvertAll(s2_temp.Split(' '),int.Parse);
    
       int max=s2.Max();
    
       int min =max-100;
    
       int[] hitcount=new int[101]; 
    
        for(int i=0;i<s2.Length;i++)
        {
            hitcount[s2[i]-min]++;
        }
    
        for(int j=0;j<s1.Length;j++)
        {
            hitcount[s1[j]-min]--;
        }
    
        for(int k=0;k<hitcount.Length;k++)
        {
            if(hitcount[k]!=0)
            {
                Console.Write((k+min)+" ");
            }
        }
    
    }
    

    }