Комментарии:
Thanks
ОтветитьWell Explained .
ОтветитьSuper 👍
ОтветитьWell explained. I was able to explain in one of interview. Please add your code in comment also
ОтветитьNice explanation sir.
ОтветитьThank u so much 🤝🤝
ОтветитьBrother ur explanation is superb
ОтветитьNew subscriber thanks for this video.please keep up the good work.
ОтветитьI tried the below way and it worked
public class DuplicateCharsCountHM {
public static void main(String[] args) {
String str = "Automation Testing";
char[] charArray = str.toCharArray();
Map<Character, Integer> hm = new HashMap<>();
for (Character ch : charArray) {
if (hm.get(ch) != null) {
hm.put(ch, hm.get(ch) + 1);
} else {
hm.put(ch, 1);
}
}
Iterator<Character> iterator = hm.keySet().iterator();
while (iterator.hasNext()) {
Character next = iterator.next();
if (hm.get(next) > 1) {
System.out.println("Count of character " + next + " is: " + hm.get(next));
}
}
}
}
Very easy solution Krishna !! I see the output is sorted, is that because of the method keySet? Pls let me know.
ОтветитьAwesome solution 👏👍👌! Thanks for this!!
ОтветитьHow’s it going?! Great channel. You deserve more subscribers, I think you should check SMZeus[.]com! Since I started using it on my other channel I’m getting way more subscribers!
Ответить