Sample Input #1
"tiptop"
Sample Output #1
tptp
Sample Input #2
"TipTop"
Sample Output #2
TipTop
Sample Input #3
"tpttipptptaptptopp"
Sample Output #3
tpttpptptptptpp
code
public String changeLetters(String str){
String str1="";
for(int i=0;i<str.length();i++){
char ch1=str.charAt(i);
char ch2=str.charAt(i+2);
char ch3=str.charAt(i+1);
if(str.length()==i+1)
break;
if((ch1==116)&&(ch2==112)){
str1=str1+ch1+ch2;
i=i+2;
}else
str1=str1+ch1;
}
return str1;
When I am trying to run my code only first test case "tiptop" runs while 2nd test case fails, can you suggest where I am doing mistake.
Testcase Pass/Fail Parameters Actual Output Expected Output