The way you are explaining the logic while writing it is crystal clear even to a beginner. Thanks a lot for sharing all the videos. I have also tried the above program using Set and it worked.
@varshamishra87433 жыл бұрын
I am loving coding only because the way you explain every logic Sir... Thank you🙏
@Tistasful5 жыл бұрын
Thank you sharing your knowledge with the whole world, you are doing a great job and you are a role model!
@mohammadsuhail1371 Жыл бұрын
TBH your code complexity is more challenging for beginner level coders But seriously it motivates to learn more and more...!! Thank you :)
@sankarsan3 жыл бұрын
The best channel for Automation. Kudos to you Naveen. Keep up the good work.
@naveenautomationlabs3 жыл бұрын
Thanks a ton
@sankarsan3 жыл бұрын
For me you are a celebrity. The way you are gifting the knowledge unconditionally is invaluable. I remember one of the videos where you showed your hand writing notes during your stay in Pune. It seems everything is possible when it comes to Technology & Naveen.
@amolnawale21775 жыл бұрын
Hi Naveen, I think this can be solved using Set also, without involving Map, as below: String[] strArray = inputString.split("\\s"); HashSet set = new HashSet(); for (String arrayElement : strArray) { if(!set.add(arrayElement)) { System.out.println("Duplicate Element is : "+arrayElement); } }
@balakrishnan-jx2jp4 жыл бұрын
It is printing the duplicate elements, but where is the count.
@pavankumarkj98655 жыл бұрын
To extract all the keys of map I have used Iterator and it’s really nice that it can be achieved using Set as well in simple way. Thank you so much Naveen Bhayya.
@007elya4 жыл бұрын
Hi Pavan! Can you share your solution? Thanks!
@2anshumansehgal5 жыл бұрын
Thanks Naveen..your way of explaining things is too good!
@zareenabegum90955 жыл бұрын
Learned a lot from your videos Naveen, thanks for sharing your knowledge 📖📚📝
@parimalaperiyasamy78594 жыл бұрын
Hello Naveen, Thanks for your vedio. Its really understandable.Here are my questions, if you find time, please answer and that will help me. 1. What is the role of toLowerCase() method here, Why its not converting upper case in input to Lowercase 2. Can we use entrySet instead of Keyset for traversing the elements?
@SarangHoley5 жыл бұрын
Very much thankful for the video, much needed small but most asked topic got covered 👍😊
@vetriselvansp81054 жыл бұрын
Thank you so much Naveen. 😍 you are helping out a lot of people 👏👏👏
@anvitaravirajmetri87103 жыл бұрын
Small Suggestion, If you explain the same thing with diagram of array and hashmap would give more clarification
@zakir77195 жыл бұрын
Hi Naveen good explanation, is there any other method to find the duplicate.
@mamasahoo28972 жыл бұрын
Always the best Naveen...you are superb...
@EdClarkHYCT4 жыл бұрын
Incredibly awesome video. Keep up the great work!
@ramupanjala60035 жыл бұрын
Thanks for the video .I am looking count JSON response duplicate ? Can we use this concept in groovy ?
@chaithracheth5 жыл бұрын
To extract those values Just print wordcount. It will shows how many times each word has been repeated (this is easy)
@IntellectOnly5 жыл бұрын
Wonderful naveen. I'm a follower from dc. Great video. More!
@karthickmohan87155 жыл бұрын
Thank so much bro its very useful for my interview
@divineIncarnation5 жыл бұрын
Always so helpful videos for me. Thanks a ton :)
@bhuvanasekar603 Жыл бұрын
One more approach using hash set String line = "hey java is best java "; String[] afterSplit = line.split(" "); Set store = new HashSet(); int count =0; for(String word : afterSplit) { if(store.add(word)==false) { count++; System.out.println(word); } } System.out.println(count);
@traghavendra98285 жыл бұрын
Hi Need answer for this question by using java Write a program to check the 10 digit mobile number if it contains more than 10 digits last digits should be subtracted and if it contains less than 10 digits prefix 0 should be added.
@imranullah73552 жыл бұрын
You people can also count duplicate words in this way: public static String findingMatchingWords(String str) { int count =0; String Result = ""; String strArray[] = str.split(" "); for (int i = 0; i < strArray.length; i++) { count = 1; for (int j = i + 1; j < strArray.length; j++) { if (strArray[i].equals(strArray[j])) { count++; strArray[j] = "0"; } } if (count> 1 && strArray[i] != "0"){ Result = strArray[i]; System.out.println(Result+"----"+count); } } return Result; } public static void main(String[] args) { // call the function findingMatchingWords(" "); } Thank me later...
@shravan67045 жыл бұрын
nice broo
@mdrajeshwar12 жыл бұрын
I got one issue while finding duplicates , if we declare in the string " Java is java " that time it's not working, like java: 2 , I am trying to convert string first into lowercase but not get success. anyone help me, Thanks in advance
@pallabdutta75365 жыл бұрын
you added the key in lower case inside map....then why didnt it work for same word with upper case
@keralacodingacademykca45973 жыл бұрын
Found it really complicated
@keralacodingacademykca45973 жыл бұрын
Now it looks less complicated...did some digging...thankyou my friend!
@keralacodingacademykca45973 жыл бұрын
I used entrySet to use the getValue() method and used it in if.. to compare it to greatethan 1...and before that, itereated through the entrySet...stored the repeated word and count in variables..using set methods... .getKey() and .getValue()
@keralacodingacademykca45973 жыл бұрын
Your method is much less complex..I tried to use a file..instead of string..so hence bufferedReader came into the picture...its good that you used just hashmap and .get(key) which gives value instead of converting map to set...that's much simpler...thankyou!
@naveenautomationlabs3 жыл бұрын
Most welcome :) 🙏
@mohammadsuhail1371 Жыл бұрын
Question:- String name = "This is a sample sentence. This is another sentence"; Answer:- sentence:-2 a:-1 another:-1 this:-2 is:-2 sample:-1 Below code will help. public static void main(String[] args) { String name = "This is a sample sentence. This is another sentence"; String[] split = name.split(" "); Map mp = new HashMap(); Pattern pattern = Pattern.compile("\\p{Punct}"); for (String a : split) { String s = a.replaceAll("\\p{Punct}", "").toLowerCase(); if (mp.containsKey(s)) { mp.put(s, mp.get(s) + 1); } else { mp.put(s, 1); } } Set Y = mp.keySet(); for (String x : Y) { System.out.println(x + ":-" + mp.get(x)); } }
@santoshkumarvlogs37538 ай бұрын
line number 30 . How this is related to words[] ? I mean how these splitted words going into hashmap? Can anyone please let me know.
@WMohanty3 жыл бұрын
I am not able to understand this. How it is comparing java to java, first time it will be come heyjava
@himanshuthakur16057 ай бұрын
public class DuplicateWordsWithOccurence { public static void main(String[] args) { printDuplicateWithOccurence("Noida is a good city and Is a good very good noida good and well maintained good"); printDuplicateWithOccurence("Java Python java python"); } public static void printDuplicateWithOccurence(String str1) { int count = 1; String str2[] = str1.split(" "); for(int i = 0; i
@shanthikandasamy5 жыл бұрын
How to split if there is no space in a given string..eg:javaislanguageisjava..
@payalmodi93775 жыл бұрын
then it will be totally different question of finding duplicate letter in string. this one here is for words so there will always be space in between
@shanthikandasamy5 жыл бұрын
@@payalmodi9377 yeah I understand this is for words..I just raised a question as there is a similarity in a concept