+ 1
Please help me how to proceed..I have found the duplicates but I'm stuck now..
https://code.sololearn.com/cArJvlaCFrxi/?ref=app https://www.sololearn.com/post/945927/?ref=app
6 Answers
+ 4
Roy Kapoor what arsenic means is to do something like this ,
https://code.sololearn.com/cgOnHDny21r6/?ref=app
Now as you see you have an array with frequency of numbers appearing , just check for a number less than 2 and output yes or no , and adjust constraints as well.
+ 3
Here's how I would go about solving this one :-
1) create an array of size (n) and initialise every index with value 0 ( this array will represent the frequency of the elements occured in the input array )
2) while traversing the input digits, increment the frequency at index accordingly.
3) traverse the entire frequency array and see if all the numbers occured atleast 2 times or not
+ 3
Roy Kapoor the idea is to simply traverse all the integers from 1 to N and check if the frequency of the number is present atleast twice in the input array or not.
here's a brute force solution :-
For every element in set [1,N] loop over the entire input array to see if that perticular number is present at least twice or not.
Although the solution I gave you before is much optimised that this (in terms of time complexity) but if you find that comparatively complicated then try going for brute force first.
+ 1
Can you please help me in code..