I want to know the test cases which are failing. There are 4 testcases and my code only passes 1. What are the remaining test cases which are failing??
import java.util.Scanner;
public class StringRemoveDuplicates {
public static void main(String[] str){
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
System.out.println(stringRemoveDuplicates(input,0));
}
private static String stringRemoveDuplicates(String input,int selectedIndex){
if(selectedIndex == input.length() - 1 ){
String result = input.substring(selectedIndex,input.length());
return result;
}
for(int x=selectedIndex; x<input.length()-1 ; ++x){
String currentchar = input.substring(x,x+1);
String nextchar = input.substring(x+1,x+2);
if(currentchar.equalsIgnoreCase(nextchar)){
StringBuffer sb = new StringBuffer(input.substring(0,x+1));
sb.append(input.substring(x+2));
input = sb.toString();
}
stringRemoveDuplicates(input,x+1);
}
return input;
}
}