public class PresentIn3 {
static String testcase1="sunil";
static String testcase2="anil";
static String testcase3="bidhu";
public static void main(String args[]){
PresentIn3 testInstance=new PresentIn3();
boolean result=testInstance.findPresenceOfchar(testcase1,testcase2,testcase3);
System.out.println(result);
}
public boolean findPresenceOfchar(String str1, String str2,String str3){
char temp=' ';
boolean caseIs=false;
String foundMax="";
String foundThisChar="";
int i=0,countAtStr2=0,countAtStr3=0;
int lenOfStr2=0,lenOfStr3=0;
while(str1.length()>0){
System.out.println("str1 length issss"+str1.length());
temp=str1.charAt(i);
foundThisChar=str1.valueOf(temp);
System.out.println("foundThisChar issssss"+foundThisChar);
for(int j=0;j<str2.length();j++){
System.out.println("jjjjjjjjjjjj"+j);
if(str2.regionMatches(j, foundThisChar,0,foundThisChar.length())){
countAtStr2++;
System.out.println("countAtStr2 issssss"+countAtStr2);
}
}
for(int l=0;l<str3.length();l++){
System.out.println("l issssssss"+l);
if(str3.regionMatches(l, foundThisChar,0,foundThisChar.length())){
countAtStr3++;
System.out.println("countAtStr3 isssssss"+countAtStr3);
}
}
str1= str1.replace(foundThisChar,"");
str1=str1.replaceAll("\\s+","");
System.out.println("str1 isssssss::::"+str1);
if(countAtStr2==0&&countAtStr3==0)
caseIs=false;
else if(countAtStr2>=1&&countAtStr3>=1){
foundMax=foundMax+temp;
caseIs=true;
System.out.println(caseIs);
break;
}
else
caseIs=false;
countAtStr2=0;
countAtStr3=0;
}
return caseIs;
}
}
static String testcase1="sunil";
static String testcase2="anil";
static String testcase3="bidhu";
public static void main(String args[]){
PresentIn3 testInstance=new PresentIn3();
boolean result=testInstance.findPresenceOfchar(testcase1,testcase2,testcase3);
System.out.println(result);
}
public boolean findPresenceOfchar(String str1, String str2,String str3){
char temp=' ';
boolean caseIs=false;
String foundMax="";
String foundThisChar="";
int i=0,countAtStr2=0,countAtStr3=0;
int lenOfStr2=0,lenOfStr3=0;
while(str1.length()>0){
System.out.println("str1 length issss"+str1.length());
temp=str1.charAt(i);
foundThisChar=str1.valueOf(temp);
System.out.println("foundThisChar issssss"+foundThisChar);
for(int j=0;j<str2.length();j++){
System.out.println("jjjjjjjjjjjj"+j);
if(str2.regionMatches(j, foundThisChar,0,foundThisChar.length())){
countAtStr2++;
System.out.println("countAtStr2 issssss"+countAtStr2);
}
}
for(int l=0;l<str3.length();l++){
System.out.println("l issssssss"+l);
if(str3.regionMatches(l, foundThisChar,0,foundThisChar.length())){
countAtStr3++;
System.out.println("countAtStr3 isssssss"+countAtStr3);
}
}
str1= str1.replace(foundThisChar,"");
str1=str1.replaceAll("\\s+","");
System.out.println("str1 isssssss::::"+str1);
if(countAtStr2==0&&countAtStr3==0)
caseIs=false;
else if(countAtStr2>=1&&countAtStr3>=1){
foundMax=foundMax+temp;
caseIs=true;
System.out.println(caseIs);
break;
}
else
caseIs=false;
countAtStr2=0;
countAtStr3=0;
}
return caseIs;
}
}
No comments:
Post a Comment