In this I have solved the question but it shows time limit error.
Regarding Exist or Not
change line no 23 :
for(int i=0;i<num;i++)
In this I have solved the question but it shows time limit error.
change line no 23 :
for(int i=0;i<num;i++)