+ 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

19th Feb 2021, 2:33 PM
Perplexed Coder
Perplexed Coder - avatar
6 Antworten
+ 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.
19th Feb 2021, 5:56 PM
Abhay
Abhay - avatar
+ 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
19th Feb 2021, 3:19 PM
Arsenic
Arsenic - avatar
+ 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.
19th Feb 2021, 4:04 PM
Arsenic
Arsenic - avatar
+ 2
Thank a lot Arsenic , Abhay 🙏🙏😃🤗
19th Feb 2021, 6:01 PM
Perplexed Coder
Perplexed Coder - avatar
+ 1
Abhay , Arsenic please help..
19th Feb 2021, 3:00 PM
Perplexed Coder
Perplexed Coder - avatar
+ 1
Can you please help me in code..
19th Feb 2021, 3:32 PM
Perplexed Coder
Perplexed Coder - avatar