Hey Naveen, awesome video... 👍 For other viewers, don't use brute force method if there are more than 2 duplicate entries... it will print the duplicate values multiple times... We can still use, if we keep adding the duplicate item to the HashSet and print the set outside of the loops... // red color is appearing 3 times in the list String colors[] = {"red", "blue", "white", "black", "blue", "grey", "red", "pink", "red"}; Set colorsSet = new HashSet(); for (int i=0; i
@@naveenautomationlabs Superb Video I guess this Ashok Comment is applies for the second way of finding Duplicate element that is with Only hashset. in the Second way as well if there are more then 2 duplicate element then it will keep printing that element. String data[] = {"Amazone","Flipkart", "Myntra", "Amazone","ClubFactory", "Myntra","Amazone"}; HashSet set = new HashSet();
for(String s: data) {
if(set.add(s)==false) {
System.out.println(s); }; } This will print 2 times Amazone in out put. My question over here is , in interview if they are asking the same question then , which is the best way for finding duplicate element ? i guess HashMap is the correct way .. is my understanding correct ?
@@shaileshchauhan7043 Yes it is. It will print the element 2nd time if it all total 3 similar element are present and so on.To avoid that we have to add the elements into a Set.
Thank you for your efforts in showing various solutions for the same problem, Speaking of real time why/what is the best solution to be used? Keeping performance, memory and iterations etc. If you can add to your videos would be even much helpful.
Really helpful. This series is so informative.🙏 If you want to update your self, follow this channel and you can understand any concepts very easily. The explanation is too good.😊Keep it up sir👍
Using brute force,if Amazon is coming 3 times, it will print Amazon 2 times. And yes the question is to find duplicate elements but we should have something that print the repeatative elements
Inside the interior loop you can use a counter and count the number of entries. If counter is greater than 1 just print the string value and the counter value. Make the counter 0 once u get out of interior loop. Problem solved.
Hello Naveen, Thanks to your wonderful videos , i got my new job in the market. what you prefer me to learn for mobile browser testing and debugging. I already worked with selenium to use mobile emulator and sauce labs and browser stack. I am not sure about the UI testing for mobile browser testing, do you have any specific video for mobile browser testing?
Fastest and shortest way: String[] strings = {....}; Set set = new HashSet(); Arrays.stream(strings).filter(s -> !set.add(s)).forEach(System.out::println);
I find your videos very useful. Thank you for such well explained videos !!! I have provided solution with a single pass in case of HashMap. HashMap map = new HashMap(); for(String element : infra){ if(map.containsKey(name)) System.out.println(element); else map.put(element, 1); }
I also want to print how many time the duplicate element is occuring in the line System.out.println(infra[i]);...could yo u please tell me what to type??
HI Naveen, in interivew the interviewer ask me explain with examples for the below terms. I was not able to give statifactory answer. For example; what documenation do. She was looking for defination. It would be greate help to our testing community if you elaborate all the terms. Regards Gaurishankar Maven handles following activities of a developer Build Documentation Reporting Dependencies SCMs Releases Distribution Mailing list
Hey Naveen, awesome video... 👍
For other viewers, don't use brute force method if there are more than 2 duplicate entries... it will print the duplicate values multiple times... We can still use, if we keep adding the duplicate item to the HashSet and print the set outside of the loops...
// red color is appearing 3 times in the list
String colors[] = {"red", "blue", "white", "black", "blue", "grey", "red", "pink", "red"};
Set colorsSet = new HashSet();
for (int i=0; i
Yeah correct :)
@@naveenautomationlabs Superb Video
I guess this Ashok Comment is applies for the second way of finding Duplicate element that is with Only hashset.
in the Second way as well if there are more then 2 duplicate element then it will keep printing that element.
String data[] = {"Amazone","Flipkart", "Myntra", "Amazone","ClubFactory", "Myntra","Amazone"};
HashSet set = new HashSet();
for(String s: data) {
if(set.add(s)==false) {
System.out.println(s);
};
}
This will print 2 times Amazone in out put.
My question over here is , in interview if they are asking the same question then , which is the best way for finding duplicate element ? i guess HashMap is the correct way .. is my understanding correct ?
@@shaileshchauhan7043 Yes it is. It will print the element 2nd time if it all total 3 similar element are present and so on.To avoid that we have to add the elements into a Set.
What a series of questions you are posting🎉🎉
Thanks a lot for such awesome videos. This series has helped a lot in preparing for my interviews.
U explain things quite well please keep uploading more videos like this
Thank you for your efforts in showing various solutions for the same problem, Speaking of real time why/what is the best solution to be used? Keeping performance, memory and iterations etc. If you can add to your videos would be even much helpful.
Thanks Naveen for the awesome videos. I feel my voice was heard. This would immensely help in prepping for many interviews. Greatly appreciate it. 🙏
Happy to help:)
mast hai sir aapka ye series. Thank You so much
You are The Best!!!!!!!!
your questions gives a lot of knowledge also increases the interest in java keep motivating us thanks.
Thank You Naveen, was looking for something on this...
Thank you a lot brother
3. HashMap
Map infraMap = new HashMap();
Setduplicates = new HashSet();
for (String e:infra) {
if(infraMap.containsKey(e)){
duplicates.add(e);
continue;
}
infraMap.put(e,1);
}
for (String dups:duplicates
) {
System.out.println(dups);
}
Really helpful. This series is so informative.🙏 If you want to update your self, follow this channel and you can understand any concepts very easily. The explanation is too good.😊Keep it up sir👍
Very good content
super good explanation
Really helpful
Hello naveen Sir
For 2 HashSet Solution
Eg:10, 11, 22, 10, 11, 22, 22, 13 ,17
O/P:10,11,22,22
Good one Naveen. Keep doing. Also, when you get a chance please do some interviews questions on the custom objects. Thanks.
Sure I will
Please start series of J2EE with spring Boot, Hibernate and JPA also🙏
Thank you so much
Thank you
You're welcome
Good one Naveen!!!
Using brute force,if Amazon is coming 3 times, it will print Amazon 2 times. And yes the question is to find duplicate elements but we should have something that print the repeatative elements
Exactly Rohit... Even I was thinking same
Inside the interior loop you can use a counter and count the number of entries. If counter is greater than 1 just print the string value and the counter value. Make the counter 0 once u get out of interior loop. Problem solved.
Hello Naveen,
Thanks to your wonderful videos , i got my new job in the market. what you prefer me to learn for mobile browser testing and debugging. I already worked with selenium to use mobile emulator and sauce labs and browser stack. I am not sure about the UI testing for mobile browser testing, do you have any specific video for mobile browser testing?
super helpful
Fastest and shortest way:
String[] strings = {....};
Set set = new HashSet();
Arrays.stream(strings).filter(s -> !set.add(s)).forEach(System.out::println);
I find your videos very useful. Thank you for such well explained videos !!! I have provided solution with a single pass in case of HashMap.
HashMap map = new HashMap();
for(String element : infra){
if(map.containsKey(name))
System.out.println(element);
else
map.put(element, 1);
}
hi, Naveen can you make some videos in API automation interview questions using rest assured thanks a lot!
for the brute force, don't we need to use break in the condition, what will happen if same element is there 3 or more times
I thought the same problem. What we can update the solution to make it work?
I also want to print how many time the duplicate element is occuring in the line System.out.println(infra[i]);...could yo u please tell me what to type??
If we use integar instead of strings then what we need to change in hashmap code?
Hi Naveen, keep rocking.
But see some hackers here mentioned vor today ande gen in in comments. What are they?? Hope they won't spoil your video
spammers, ignore them.
But naveen i request you to cover about streams and then use it directly using streams is a bit confusing and difficult to understand for me
HI Naveen,
in interivew the interviewer ask me explain with examples for the below terms. I was not able to give statifactory answer.
For example; what documenation do. She was looking for defination. It would be greate help to our testing community if you elaborate all the terms.
Regards
Gaurishankar
Maven handles following activities of a developer
Build
Documentation
Reporting
Dependencies
SCMs
Releases
Distribution
Mailing list
SOLID principles sir. 😓
Set has own property of remove duplicates....
How I print out put like if it is coming two times thn print two times
Input : [1, 1,4,7,5,3,3]
Output :[1, 1,3,3]