Getting wrong ans

getting repeated elements in ans, please check my code

Hey @shivamgoel150
Please re watch the video.
Otherwise problem in your code is :While loop is nested inside for loop but in actual solution they are running independently.