My code is not working pls correct it

import java.util.Scanner;
public class NiceString
{
public static String convertToNiceString(String s,int n)
{
String nice = β€œβ€;
for(int i = 0; i<n;i++)
{
if(1 <= n && n<= 104)
{ if(s.length() <2)
return s;
else if(s.charAt(n-1) == s.charAt(n-2))
return convertToNiceString(s.substring(n-1),n);
else
return s.charAt(n-1) + convertToNiceString(s.substring(n-2),n);

       return nice + s.charAt(n-1) + convertToNiceString(s.substring(n-2),n);
      }
      }

}
public static void main(String[] args)
{
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();

    System.out.println(convertToNiceString(s,n-1));

}

}

your input doesnt have n you just need to input string

  • Obtain the result for the substring starting at index 1 recursively. Store this result in a new string , say β€˜ros’ .
  • Check whether the first character of ros and original string are same. If so , return ros only omitting s[0].
  • Else return s[0] + ros.