Java coding interview questions || Print duplicate occurrences of string in java

  Рет қаралды 236,162

Selenium Express

Selenium Express

Күн бұрын

Пікірлер: 115
@rakeshsaw
@rakeshsaw 2 жыл бұрын
I am impressed of your video and also I am first time commenting in any video.
@subramanianchenniappan4059
@subramanianchenniappan4059 5 жыл бұрын
I am an experienced java developer. Please upload more videos. It will be helpful for interviews. Thanks for this video
@sabinchand4895
@sabinchand4895 3 жыл бұрын
10:20 (Line 15) if(hm.get(tempString) != null) I think it checks 'value', not 'key'.
@KanagalingamJothi
@KanagalingamJothi 5 жыл бұрын
String key = "I am am learning java java "; String[] words = key.split(" "); HashSet set = new HashSet(); for (String s : words) { if (!set.add(s)) { Log.d("TAG", s); } else { set.add(s); } }
@chidanandasutar9105
@chidanandasutar9105 2 жыл бұрын
Thanks for this video 🙏
@meghavikshatriya5637
@meghavikshatriya5637 2 жыл бұрын
I would say go with java 8 stream, it would be only one line of code!
@MsDhruv001
@MsDhruv001 3 жыл бұрын
Somewhere i have feeling that you made problem more complex while solving
@akshaybedre6804
@akshaybedre6804 3 жыл бұрын
Video ke starting me jo Audio hai. Kya nam hai uska???
@fafunmotavines
@fafunmotavines 5 жыл бұрын
You explain us in a very practical manner, easy to understand...
@suhedaerturk215
@suhedaerturk215 2 жыл бұрын
Great explanation!
@ankitshah4211
@ankitshah4211 5 жыл бұрын
Nice explanation
@simm5622
@simm5622 2 жыл бұрын
Thank you. 🏆🏆🏆
@sarath6789
@sarath6789 5 жыл бұрын
Concise code String str ="I am am learning learning learning Java Java Java"; String []st=str.split(" "); int count=0; Map stor = new HashMap(); for(String s:st) { if(stor.containsKey(s)) { count++; stor.put(s,count); } else { count=1; stor.put(s,count); } }
@user1994gms
@user1994gms 4 жыл бұрын
Contains shouldn't be used which leads to performance issue
@mokshanachannel9587
@mokshanachannel9587 4 жыл бұрын
What if string has"i am learning Java and Java"
@user1994gms
@user1994gms 4 жыл бұрын
@@mokshanachannel9587 above program is wrong.. If repeated words are not contiguous count will be wrong.. Consider 'am' word is in sentence. Count is 1.. Next word is different.. count is 1 Again 'am' in a sentence.. count++ becomes 2 Next word is different.. count is 1 Again 'am' here count should be 2+1, but the above program returns 1+1 which is incorrect
@thallasaikumar1778
@thallasaikumar1778 3 жыл бұрын
i love the way you explain the things
@JoshMolina
@JoshMolina 5 жыл бұрын
Great example! Thanks for sharing. Keep up the great work!
@vicentedominic2753
@vicentedominic2753 3 жыл бұрын
i know Im randomly asking but does anyone know a trick to log back into an Instagram account..? I was stupid forgot the account password. I would appreciate any assistance you can offer me!
@rogerwilder8185
@rogerwilder8185 3 жыл бұрын
@Vicente Dominic Instablaster =)
@vicentedominic2753
@vicentedominic2753 3 жыл бұрын
@Roger Wilder I really appreciate your reply. I found the site thru google and Im in the hacking process atm. Seems to take quite some time so I will reply here later when my account password hopefully is recovered.
@vicentedominic2753
@vicentedominic2753 3 жыл бұрын
@Roger Wilder it did the trick and I now got access to my account again. Im so happy! Thanks so much you saved my ass!
@rogerwilder8185
@rogerwilder8185 3 жыл бұрын
@Vicente Dominic You are welcome =)
@nishaant9
@nishaant9 5 жыл бұрын
good one
@hasanath9702
@hasanath9702 4 жыл бұрын
How to remove duplicate in a string (using java) can you please make a video for that ...Thanks
@krish.gottipati
@krish.gottipati 3 жыл бұрын
Super bro,
@hondahnesscb3505
@hondahnesscb3505 5 жыл бұрын
Starting music is same which Guru Maan Sir is using.
@prasannavadada6349
@prasannavadada6349 5 жыл бұрын
Awesome explanation brother keep rocking 🎸🎶🎶
@emilefeltesse
@emilefeltesse 3 жыл бұрын
Cool. But what if we want out the words in the same order as they appear in the initial sentence?
@shakelahmed9722
@shakelahmed9722 4 жыл бұрын
Great explaining.Keep it up...
@gamzeguresci5546
@gamzeguresci5546 5 жыл бұрын
Hi thank you for the video. Can you also write the unit test for this example ?
@ganeshsurya8115
@ganeshsurya8115 5 жыл бұрын
good boss
@nitinpatil1163
@nitinpatil1163 6 жыл бұрын
good explanation , whats happens in case of Variable? if there is same variable in both parent and child class then which one gets called ?
@anjaliyadav8929
@anjaliyadav8929 3 жыл бұрын
Vdo👌
@tejeswarv450
@tejeswarv450 6 жыл бұрын
Awesome explanation sir .... representation is suuuuuper....
@singsarav
@singsarav 5 жыл бұрын
Will it be easier if lambda was applied?
@rajp3059
@rajp3059 6 жыл бұрын
Superb bro...keep rocking for ur explanation bro...
@sureshs2510
@sureshs2510 6 жыл бұрын
Really worth videos thanks a lot .. could you please prepare one video of java 8 features please
@SeleniumExpress
@SeleniumExpress 6 жыл бұрын
Thanks, Suresh. Sure will prepare one soon.
@sureshs2510
@sureshs2510 6 жыл бұрын
Thanks for replying
@sourav2726
@sourav2726 4 жыл бұрын
Just beautiful ❤️. make more videos man
@bhupendradhore8574
@bhupendradhore8574 5 жыл бұрын
Why you have used iterator you can use for each loop for iterating through values
@harishbs89
@harishbs89 5 жыл бұрын
Can use entrySet() which returns Entry Interface.
@sanjaypaudel3296
@sanjaypaudel3296 2 жыл бұрын
Namaste guru
@fafunmotavines
@fafunmotavines 5 жыл бұрын
Nicely explained....
@ansilbabariya9713
@ansilbabariya9713 3 жыл бұрын
You can use containskey method instead of get
@sachingupta2859
@sachingupta2859 3 жыл бұрын
Please try- Find occurrences of given substring in given string with optimized code.
@kajalsarawgi3457
@kajalsarawgi3457 5 жыл бұрын
thanks brother, you are teaching exactly the way i want. :)
@ankitpriyadarshi2028
@ankitpriyadarshi2028 5 жыл бұрын
Make videos on jdbc and core java
@VC-kj9yx
@VC-kj9yx 6 жыл бұрын
Very nice tutorial
@SeleniumExpress
@SeleniumExpress 6 жыл бұрын
Thanks, Vidhit.😊
@shobhitss
@shobhitss 5 жыл бұрын
If I want the input through excel and display the duplicates. How to do?
@karunakardatla2048
@karunakardatla2048 6 жыл бұрын
super explanation bro
@tabishrizwan9137
@tabishrizwan9137 5 жыл бұрын
you can use in this way also it's simple like your previous program bro public class duplicatechar { private static void findDuplicateChar(String string) { char[] ch = string.toCharArray(); HashMap hm = new HashMap(); for (char c : ch) { if (hm.get(c) != null) { hm.put(c, hm.get(c) + 1); } else { hm.put(c, 1); } }
@umeshrgpv
@umeshrgpv 6 жыл бұрын
Do you know how to create videos using our own laptop.. which software can be used without any charges?
@playwithknight007
@playwithknight007 6 жыл бұрын
what about spaces, if we have spaces how to remove that spaces while counting
@bhupendradhore8574
@bhupendradhore8574 5 жыл бұрын
You can use replace function to replace space with no-space Replace(" ","") like this
@theLastOneTaken
@theLastOneTaken 2 жыл бұрын
Instead of hashmap u should've used set cuz it doesn't store duplicate values...
@AmeyaNanarkar76625
@AmeyaNanarkar76625 4 жыл бұрын
Why not used hm.contains(tempString) in if condition at line 15
@reddydivya8055
@reddydivya8055 6 жыл бұрын
Thanks sir! Great explanation
@Mylastpage
@Mylastpage 6 жыл бұрын
static void findDuplicate(String text) { String[] strAr = text.split(" "); Set set = new HashSet(); Map map = new HashMap(); for(int i=0;i
@IASGURUADVANCEPREPARATION
@IASGURUADVANCEPREPARATION 6 жыл бұрын
Bro can know to make the table format (match type questionsin strings
@aniketchoubey2027
@aniketchoubey2027 6 жыл бұрын
Awwsome thnks
@abulhasanath1471
@abulhasanath1471 4 жыл бұрын
print duplicate characters in a string (using java) can you please make a video for that also how to remove duplicate string or char ..thank you
@damodaranm3044
@damodaranm3044 4 жыл бұрын
if u want a video cantact me in whatsapp +917358252858
@hasanath9702
@hasanath9702 4 жыл бұрын
@@damodaranm3044 How to remove duplicate in a string (using java) can you please make a video for that ...Thanks using same code
@jimmyfallon1890
@jimmyfallon1890 5 жыл бұрын
I paused the video and did a dirty log(n)2 version.... String str = "I am am learning java java "; String[] result = str.split(" "); ArrayList list = new ArrayList(); for(int i = 0; i
@SauravKumar-cs4oj
@SauravKumar-cs4oj 5 жыл бұрын
Good code but what in case we also want the count of the repeated words?
@bulutcakan3048
@bulutcakan3048 6 жыл бұрын
why you did not use SET for find duplicate values.
@iam_ms9723
@iam_ms9723 5 жыл бұрын
Because we needed key and values pair so here he's using map
@sauravSingh037
@sauravSingh037 5 жыл бұрын
Thank you 😊😘❤️
@abhijeetdeshmukh9138
@abhijeetdeshmukh9138 5 жыл бұрын
What if string contains punctuation marks like "I am working on java. Because java is my favourite language." In this case java is not showing as duplicate word. Because there is full stop. Please explain one example with punctuation mark.
@fafunmotavines
@fafunmotavines 5 жыл бұрын
First split based on punctuation using regex and one more for loop...that will work
@randomize8053
@randomize8053 6 жыл бұрын
why we used iterator there , am not getting it ?
@Uda_dunga
@Uda_dunga 6 жыл бұрын
to iterate ..its just like for loop
@xcreatorminigames6227
@xcreatorminigames6227 6 жыл бұрын
Very nice friend, but you can use the computer to work as a blackbord, so we can see your writings better, and the sound is better too :-)
@SeleniumExpress
@SeleniumExpress 6 жыл бұрын
Thank you, Vinicius.. I will keep your suggestions in mind. Thank you for taking time and writing a feedback. Have a nice time 😊
@akkitech6259
@akkitech6259 5 жыл бұрын
String s="this is java program" I want to find the index of 'is' in string. But when I find using indexOf("is") it return the index of first is which is in 'this' word. Can u tell me how to find that....
@rkoustubha9664
@rkoustubha9664 5 жыл бұрын
In your case, you can use lastIndexOf("is")
@basernishant
@basernishant 4 жыл бұрын
use " is" give some gap i think
@SreeConnects
@SreeConnects 5 жыл бұрын
nice but very lengthy code
@kothiyan5655
@kothiyan5655 5 жыл бұрын
Can anyone explain hm.put(tempting,him.get(tempstring)+1)
@Mylastpage
@Mylastpage 6 жыл бұрын
concurrentHaspMap would not be better? where you are iterating, you can remove all the elements having value 1.
@manikanta783
@manikanta783 6 жыл бұрын
Frd super videos, but I want how to remove duplicates in string
@r.o.9322
@r.o.9322 4 жыл бұрын
ArrayList d = new ArrayList(); String sentence = "I am am learning Java Java"; String[] s = sentence.split(" "); for (String a : s) { if(!d.contains(a)) { d.add(a); } } System.out.println(d);
@kraljeliman2748
@kraljeliman2748 6 жыл бұрын
"right?"
@harshittiwari3947
@harshittiwari3947 6 жыл бұрын
Bro make a method in java that iterate prime number between 0-200 and return the prime number between 0-20 and 70-90
@SeleniumExpress
@SeleniumExpress 6 жыл бұрын
Hi Harshit.Hope below code will help.Revert back for any further query. static void check() { ArrayList list = new ArrayList(); for(int i = 0 ; i= 0 && tempInt = 70 && tempInt
@suyashsahu4546
@suyashsahu4546 6 жыл бұрын
or u can simply write like this.. for (Iterator iterator = a.iterator(); iterator.hasNext();) { Integer obj = (Integer) iterator.next(); if (obj>=2 && obj=70 && obj
@damodaranm3044
@damodaranm3044 4 жыл бұрын
i wonder why do u use hashmap any datastucture can do this String str = "i am am learning java java"; String[] arr = str.split(" "); ArrayList al = new ArrayList(); for(int i = 0 ; i < arr.length ; i++ ) { if(!al.contains(arr[i])) { al.add(arr[i]); } else { System.out.println(arr[i]); } } }
@sachinsahu817
@sachinsahu817 6 жыл бұрын
{ map.put(str1, map.get(str1) + 1); } this line is not working. error message - The operator + is undefined for the argument type(s) Object, int can you please what I can do here? Thanks in Advance.
@krishnasingh9111
@krishnasingh9111 6 жыл бұрын
I am getting same error if resolve please post your solution ..
@JP-yf2kp
@JP-yf2kp 6 жыл бұрын
you cannot get such a error:- check this program package myapp; import java.util.HashMap; import java.util.Map; public class DuplicateString { public static void main(String[] args) { String str = "I am am learning java java"; DuplicateString obj = new DuplicateString(); obj.calculateDuplicateString(str); } public void calculateDuplicateString(String str) { Map string_literals_map = new HashMap(); String [] str_array = str.split(" "); for (String str_literals : str_array) { //System.out.println(str_literals); if(string_literals_map.containsKey(str_literals)) { string_literals_map.put(str_literals, string_literals_map.get(str_literals) + 1); } else { string_literals_map.put(str_literals, 1); } } System.out.println(string_literals_map); } }
@JP-yf2kp
@JP-yf2kp 6 жыл бұрын
@@krishnasingh9111 package myapp; import java.util.HashMap; import java.util.Map; public class DuplicateString { public static void main(String[] args) { String str = "I am am learning java java"; DuplicateString obj = new DuplicateString(); obj.calculateDuplicateString(str); } public void calculateDuplicateString(String str) { Map string_literals_map = new HashMap(); String [] str_array = str.split(" "); for (String str_literals : str_array) { //System.out.println(str_literals); if(string_literals_map.containsKey(str_literals)) { string_literals_map.put(str_literals, string_literals_map.get(str_literals) + 1); } else { string_literals_map.put(str_literals, 1); } } System.out.println(string_literals_map); } }
@manish1315
@manish1315 6 жыл бұрын
bhai itni coding to kabhi yaad nahi hogi kya golmaal hai hasmap to java mein mene abhi padha bhi nahi hai dara diya apne mujhe
@SeleniumExpress
@SeleniumExpress 6 жыл бұрын
Hi Manish, I appreciate ki apne at list video dekha, hashmap ka concept Na jante huea v.. Mein jab Ye Sab sikhta tha, I also had the same feelings and even I was not trying to watch these kind of programs. 😀so you are already doing better than me 👍 So avi Apko pehele hashmap ka concepts sikhna hai.. Then you need to play with these logic's. And before you try solving any kind of logic, make sure you know ki app Kya karne Ja rahe ho.. Then Ye Bahot asan lagega.. I know you can do it once you understand the concept 😊👍
@manish1315
@manish1315 6 жыл бұрын
@@SeleniumExpress sir ek last question meine bsc cs last year complete kar loonga lekin abhi tak hamein is baare mein bataya kyun nahi sir mene java ka course bhi kiya tha lekin unhone bhi is baare mein nahi bataya kya ye advanced level ka to nahi hai vaise mein java ke advanced level like jsp servlet , netbeans ide project , like stand alone applicaiton , mysql sever , etc ke baare mein janta hoon kya kisi company mein interview ke liye java ke core concept hi puchhe jaate hai koi netbeans ke graphical question nahi puchta kya please help
@SeleniumExpress
@SeleniumExpress 6 жыл бұрын
Manish,ye sare logical programs interviews mein Bahot importance rakhte hain.. Most of the time the first round is problem solving round where you will get questions like this.. So ap collection framework pe jyada homework kijiye.. Because most of the questions you will get from there.
@princegamingff3744
@princegamingff3744 5 жыл бұрын
hi plz upload some video
@rishirakh1
@rishirakh1 3 жыл бұрын
I thought I opened Guruman fitness video 😂
@vinayakkanade1782
@vinayakkanade1782 3 жыл бұрын
public static void countDuplicateWord(String string){ String sourceArr[] = string.split(" "); Map stringIntegerMapMap = new HashMap(); for (String str : sourceArr) { Integer previousValue = stringIntegerMapMap.put(str, 1); if (previousValue != null) { stringIntegerMapMap.put(str, previousValue + 1); } } System.out.println(stringIntegerMapMap); } public static void countDuplicateCharacter(String word){ Map characterIntegerMap = new HashMap(); for (int i = 0; i < word.length(); i++) { Integer previousValue = characterIntegerMap.put(word.charAt(i), 1); if (previousValue != null) { characterIntegerMap.put(word.charAt(i), previousValue + 1); } } System.out.println(characterIntegerMap); }
@KanagalingamJothi
@KanagalingamJothi 5 жыл бұрын
String key = "I am am learning java java "; String[] words = key.split(" "); for (int i = 0; i < words.length; i++) { for (int j = i + 1; j < words.length; j++) { if (words[i].equalsIgnoreCase(words[j])) { Log.d("TAG", words[i]); } } }
@mohitpant8431
@mohitpant8431 5 жыл бұрын
But in this case time complexity is O(n^2).
@ViratKohali.television
@ViratKohali.television 6 жыл бұрын
how to sovle xml parsing error in spring
@mrnagalakshmi93
@mrnagalakshmi93 4 жыл бұрын
Annoying slang... sorry... unable to graspe the content coz of this slang.... looks artificial....
@Raj-ql2vz
@Raj-ql2vz 2 жыл бұрын
U copied background music from gurumann
@abhay6276
@abhay6276 2 жыл бұрын
You are creating complex coding...when beginners will watch your coding then he will suicide...
@ytbshorts1741
@ytbshorts1741 2 жыл бұрын
😂😂😂
@sivaprasad8333
@sivaprasad8333 3 жыл бұрын
No clarity
@aazaa7334
@aazaa7334 2 жыл бұрын
String str1 = "I am am walking walking java java java java"; String[] strings = str1.split(" "); Map myMap = new HashMap(); for(String x : strings){ if(!myMap.containsKey(x)){ myMap.put(x,1); } else{ myMap.put(x,myMap.get(x) + 1); } } Set keys = myMap.keySet(); for(String key: keys){ if(myMap.get(key)> 1){ System.out.println(key); } }
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Why string is immutable in java || The 4 reasons you must know || part 1
20:53
Better Java Streams with Gatherers - JEP Cafe #23
1:13:32
Java 8 Streams programs you must prepare for Java Interviews
23:02
MUST KNOW junior role JAVA interview questions
42:15
Keep On Coding
Рет қаралды 142 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23