Hey folks!
Good day...
Today I solved and practiced one of the tasks that is given by the trailner.
Task : To Remove the Duplicate elements in array
My Logic :
As a beginner and human what we will do to solve this problem is we should take the number and compare it to another number if it is same that is duplicate . After we find the duplicted we need to remove that element .The Same logic I implemented in my code because first I have my hand in one number compare it to next number if it is same skip the change of hand to the next number . If it is not same we need to change our hand to the next number that's how we loop through the array and find the duplicate. In my code I didn't remove the duplicate and pushed the duplicates to the end of the array.After that I created a variable to store the count of the result and loop through the count of the nums and printed it.
It's my kind of beginner approach (human thinking approach) there are so many methods to solve this problem like hashset , etc...
As a beginner for better understanding of loops and array I did it.
Code :
Output:
That's all about today.
Let's see tomorrow with another interesting blog...


Top comments (0)