Very usefull...I had interview today and the interviewer ask the same question 😂😂😂
@CodeDecode2 жыл бұрын
Hehe yess, interviewers have some set of common questions to ask from 🙂🙂
@rishiraj25482 жыл бұрын
Wow
@rushikeshgodase8498 Жыл бұрын
At that interview time you were fresher or experienced???
@vinothkumarpalanivel4355 Жыл бұрын
@@rushikeshgodase8498 i'm having 3+ year experience when I attended the interview
@umangshah93052 жыл бұрын
Can use single for loop that goes till length-1 with indexof() and lastindexof(). Check if both are different, then add to the set. This will work since we do not need count of occurrences. Set duplicates = new LinkedHashSet(); String input = "code decode"; for (int i = 0; i < input.length() - 1; i++) { if (input.indexOf(input.charAt(i)) != input.lastIndexOf(input.charAt(i))) { duplicates.add(input.charAt(i)); } }
@karthigeyanm33762 жыл бұрын
I am really a big fan of CodeDecode and I want to say this video explanation is "THE BEST" we can find in the internet for FREE. You guys are really awesome and especially ma'am, the way you explain the logics are stupendous. This channel has helped me to grap multiple offers from various MNC's for more than 10 LPA package and I wanted to thank the entire team for your efforts on all your videos and playlist. Thanks again...!!!
@CodeDecode2 жыл бұрын
sure karthikeyan we have noted the request and we will try to create it in near future
@pratiyushanand64542 жыл бұрын
Can also be solved using set - add chars to the set, if add() in set returns false, it means it is a duplicate value. Just store it.
@jaivikkotadiya7308 ай бұрын
Just add all char in set and then compare size of set with length of string. This will be more compact solution
@sourabhchougule56427 ай бұрын
I really appreciate your videos and lectures these helped me to prepare well. For the deplicate elements in string i have other solution; i.e public static Set duplicatesByUsingLastIndexOfMethod(String str) { Set duplicateCharacters = new LinkedHashSet(); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (str.lastIndexOf(c) > i) { duplicateCharacters.add(c); } } return duplicateCharacters; } is it correct @CodeDecode ?
@nishankjain87392 жыл бұрын
I really like how you explain the concepts. Can you please make a video series (2-3 vids) for spring data jpa. A lot of interviewers have focused on this and sadly it was hard to fool them without complete knowledge on it. Thanks
@CodeDecode2 жыл бұрын
Sure Nishank we will cover them too 👍🙂
@_satveer Жыл бұрын
*At **2:35** use getOrDefault method of map & keep on incrementing them with+1 by initial setting value 0 instead of if…else* Btw nice video👌
@CodeDecode Жыл бұрын
👍👍
@mysteriouscartoontales2 жыл бұрын
Good Explanation. Please try to make videos on springs containers, JPA, Hibernate and other topics in spring. in most of the interview they asked about springs question with java.
@CodeDecode2 жыл бұрын
Sure Akash. We do have many on our channel already 👍🙂
@ashwinmarathe9844 Жыл бұрын
Very well explained
@CodeDecode Жыл бұрын
Thanks
@gyvsr2 жыл бұрын
Why we need to iterate again in 3rd approach? We can add duplicate elements into duplicates set directly after line no 26 right?
@kalekar1002 жыл бұрын
Thanks. That is simple and in detail.
@CodeDecode2 жыл бұрын
Thanks Sourabh 🙂👍
@ponnamramesh45692 жыл бұрын
I think we don't require second for loop in last 2 case's... In first for only we can add duplicate elements.
@kancharlasrimannarayana70682 жыл бұрын
int [ ] arrayforchar = new int [256] ; why we use 256bytes size here?
@CodeDecode2 жыл бұрын
www.ascii-code.com/ Look at this table. In java asciiis 256 bytes n not of 128 as in c etc. We map each string character to ascii value n store in integer array. Since it's easy to convert from character to ascii integer n vice versa, we use this technique to solve our problem.
@sureshmanne72452 жыл бұрын
Excellent explanation, thank you
@CodeDecode2 жыл бұрын
you're welcome suresh
@sonaligayake9240 Жыл бұрын
Really good explanation 😃
@CodeDecode Жыл бұрын
Thanks
@arutsudar2 жыл бұрын
Isn’t the time complexity of map operations (put and get) is O(1) ? And, the 3rd approach’s overall time complexity is O(n) ??
@CodeDecode2 жыл бұрын
Now map internally implements tree for handling collisions. So what is the time complexity of tree? It's o(logn). Hence o(nlogn)
@chiranjibidangal6184Ай бұрын
It’s great video
@CodeDecodeАй бұрын
Thanks
@sravandatha9511 Жыл бұрын
Solution using Java 8 Streams: Set characterDuplicates = Arrays.asList(string.split("")).stream() .collect(Collectors.groupingBy(Function.identity(),Collectors.counting())) .entrySet().stream().filter( e -> e.getValue()>1).map(e -> e.getKey()).collect(Collectors.toSet());
@krishnareddy-ro2rp2 жыл бұрын
Please do videos on Java Data Structers
@CodeDecode2 жыл бұрын
sure krishna we will create it soon
@rajashekar-bu8xd2 жыл бұрын
Please make a series on multithreading
@CodeDecode2 жыл бұрын
Sure Raja 👍🙂
@akshaykohale31212 жыл бұрын
Pls make one video on.. how to call stored procedure in hibernate or spring boot
@CodeDecode2 жыл бұрын
Sure 👍👍
@varunsiddarth12652 жыл бұрын
It's really very helpful
@CodeDecode2 жыл бұрын
Thanks varun
@varunsiddarth12652 жыл бұрын
@@CodeDecode keep rocking "code decode" team..🤗🤗
@rishiraj25482 жыл бұрын
Great thanks
@CodeDecode2 жыл бұрын
You are welcome
@rishiraj2548Ай бұрын
@@CodeDecode , sessions with you are worth revising. Thanks again.
@Ravikumar-gj6qw2 жыл бұрын
Hi how your coding like this , can u just refer me the links to pratice such a analyst and speed in coding plz
@swapnilmishra6972 жыл бұрын
Really nice video...
@CodeDecode2 жыл бұрын
Thanks Swapnil🙂👍
@tanveersyed10492 жыл бұрын
Mostly asked questions in interviews
@CodeDecode2 жыл бұрын
Yes it is frequently asked. 🙂
@elangovan.s78202 жыл бұрын
String s ="codedecode"; //count of duplicate characters List list1=Arrays.asList(s.split("")); Map m =list1.stream().collect(Collectors.groupingBy(Function.identity(),Collectors.counting())); System.out.println(m.entrySet()); //print only duplicate List list = Arrays.asList(s.split("")); Set set = new HashSet(); list.stream().filter(x->!set.add(x)).collect(Collectors.toSet()).forEach(System.out::println);
@akhilchowdary8142 жыл бұрын
Instead of that you can add directly into hash set because they don't allow duplicate elements
@AbhishekPandey-mi1wi2 жыл бұрын
How will you get the counts then? Also linkedhashset is a implemented class of set interface
@felix29162 жыл бұрын
In the 3rd approach maybe if you use a LinkedHashMap instead of a HashMap then you can add the chars in the order they appeared in the string. In the other hand, I didn't get why O(log(n)). Great video thanks a lot!
@rocker315902 жыл бұрын
Please create videos for Spring Transaction and Hibernate Transaction.
@CodeDecode2 жыл бұрын
sure we will create video on it soon
@rocker315902 жыл бұрын
@@CodeDecode thanks 😊
@ILuvBilli2 жыл бұрын
But now a days interviewer asked us to solve this through stream
Still didn't get why you have taken array size of 256 though we have only 26 characters in second approach
@samahmahdi55117 ай бұрын
private static Set getDuplicateCharacters1(String s) { Set set = new LinkedHashSet(); // or HashSet if u dont mind of insertion order Map map = new HashMap(); for(char ch : s.toCharArray()){ if(map.containsKey(ch)) map.put(ch, map.get(ch)+1) ; else map.put(ch, 1) ; } for(Map.Entry entry : map.entrySet() ) if(entry.getValue()>1) set.add(entry.getKey()); return set; }