Комментарии:
String a="abcdef";
String b="dghijk";
String c= "lmnopa"; can any one help me from these 3 strings to be compared and find duplicates in java8
Clean nhi dikh raha h
ОтветитьThank you sir.
ОтветитьNeed to explain How it works that's the important
ОтветитьFucking no one tell what happen when that duplicate value come more than twice . Ignorance
ОтветитьGood but You have explain more you just going on by writing the code who wil understand
ОтветитьMore Optimised Code:
public class Repeated {
public static void main(String[] args) {
String name = "Rahaman";
int count;
char ch [] = name.toCharArray();
for (int i = 0; i <name.length() ; i++) {
count =1;
for (int j = i+1; j < name.length(); j++) {
if (ch[i] == ch[j] && ch[i] != ' ') {
count++;
ch[j] = '0';
}
}
if(count> 0 && ch[i] !='0'){
System.out.print(" " + ch[i] );
}
}
}
}
Time complexity is o(n^2),which is bad, instead you can use hashmap with key as char and value as counter
ОтветитьIt's not working
Ответитьhow to find frequency of this duplicate characters??
ОтветитьVery nice bro keep it up very sort and simple
ОтветитьThanks its useful ....❤but Try to give Explaination also because it will be more helpful for beginners who they are doing coding.....
Ответитьwrong code
ОтветитьHey in this..if there are multiple characters like greater than 2 ,it will not work
ОтветитьYou simply writing program, you should trace code and explain it.
ОтветитьThis is wrong
sir
short and simple solution, keep go on....
ОтветитьChutiye agr array me hi convert krna hota to hum string ka kyo search krte
ОтветитьChala baga explain chesaru sir 🙏
ОтветитьHello sir.. It will not work when one character occurs more than two times i.e sillypointspider, o/p will come as i print two times instead of 1 coz it occured 3 times in a string and will satisfy the condition of second loop also.
ОтветитьThis program doesn't work well with string "Hello Beautiful" ??
Ответитьif i am giving input string "saraswati" the Above code is not working ,o/p should be s a but o/p coming s a a
ОтветитьSuppose take input string as "i am going to gym".
Above code is not working.
Actual O/P: i m g o g
Expect o/p should be : i m g o
Thanks,
Sruti
THanks Buddy :)
ОтветитьExcellent !!!
Ответить