<gouthampradhan>math_DecodedStringAtIndex_1.java
public String decodeAtIndex(String S, int K) {
    long product = 0;
    char lastC = S.charAt(0);
    for (int i = 0, l = S.length(); i < l; ) {
      char c = S.charAt(i);
      if (Character.isLetter(c)) {
        lastC = c;
        product++;
        i++;
        if (K == product) break;
      } else {
        long temp = (product * Integer.parseInt(String.valueOf(c)));
        if (temp == K) break;
        else {
          if (temp > K) {
            long x = (K / product);
            if ((product * x) == K) break;
            K -= (product * x);
            i = 0;
            product = 0;
          } else {
            product = temp;
            i++;
          }
        }
      }
    }
    return String.valueOf(lastC);
  }
public String var_0 ( String var_2 , int var_3 ) {
  long var_5 = 0 ;
  char var_7 = var_2 . charAt ( 0 ) ;
  for ( int var_8 = 0 , var_10 = var_2 . length ( ) ;
  var_8 < var_10 ;
  ) {
    char var_11 = var_2 . charAt ( var_8 ) ;
    if ( Character . isLetter ( var_11 ) ) {
      var_7 = var_11 ;
      var_5 ++ ;
      var_8 ++ ;
      if ( var_3 == var_5 ) break ;
    }
    else {
      long var_17 = ( var_5 * Integer . parseInt ( String . valueOf ( var_11 ) ) ) ;
      if ( var_17 == var_3 ) break ;
      else {
        if ( var_17 > var_3 ) {
          long var_18 = ( var_3 / var_5 ) ;
          if ( ( var_5 * var_18 ) == var_3 ) break ;
          var_3 -= ( var_5 * var_18 ) ;
          var_8 = 0 ;
          var_5 = 0 ;
        }
        else {
          var_5 = var_17 ;
          var_8 ++ ;
        }
      }
    }
  }
  return String . valueOf ( var_7 ) ;
}
