public static String convertToTitle(int n){
  if (n <= 0)   return "";
  StringBuilder title=new StringBuilder();
  while (n > 0) {
    n--;
    int r=n % 26;
    title.insert(0,(char)('A' + r));
    n=n / 26;
  }
  return title.toString();
}

public static String convertToTitle ( int n ) { if ( n <= 0 ) return "" ; StringBuilder title = new StringBuilder ( ) ; while ( n > 0 ) { n -- ; int r = n % 26 ; title . insert ( 0 , ( char ) ( 'A' + r ) ) ; n = n / 26 ; } return title . toString ( ) ; }
get the remainder in each loop it should be the last digit note that the map shall have 1 offset
