public static String printVertically ( String s ) {
  String result = "" ;
  HashMap < Integer , String > map = new HashMap < > ( ) ;
  Scanner sc = new Scanner ( s ) ;
  int max = Integer . MIN_VALUE ;
  while ( sc . hasNext ( ) ) {
    String st = sc . next ( ) ;
    max = Math . max ( max , st . length ( ) ) ;
  }
  sc = new Scanner ( s ) ;
  while ( sc . hasNext ( ) ) {
    String st = sc . next ( ) ;
    for ( int i = 0 ;
    i < st . length ( ) ;
    i ++ ) {
      char ch = st . charAt ( i ) ;
      map . put ( i , map . getOrDefault ( i , "" ) + ch ) ;
    }
    for ( int i = st . length ( ) ;
    i < max ;
    i ++ ) {
      map . put ( i , map . getOrDefault ( i , "" ) + "$" ) ;
    }
  }
  for ( int i = 0 ;
  i < max ;
  i ++ ) {
    String a = map . get ( i ) ;
    result += a + " " ;
  }
  return result ;
}

public static String printVertically ( String s ) { String result = " " ; HashMap < Integer , String > map = new HashMap < > ( ) ; Scanner sc = new Scanner ( s ) ; int max = Integer . MIN_VALUE ; while ( sc . hasNext ( ) ) { String st = sc . next ( ) ; max = Math . max ( max , st . length ( ) ) ; } sc = new Scanner ( s ) ; while ( sc . hasNext ( ) ) { String st = sc . next ( ) ; for ( int i = 0 ; i < st . length ( ) ; i ++ ) { char ch = st . charAt ( i ) ; map . put ( i , map . getOrDefault ( i , " " ) + ch ) ; } for ( int i = st . length ( ) ; i < max ; i ++ ) { map . put ( i , map . getOrDefault ( i , " " ) + " $ " ) ; } } for ( int i = 0 ; i < max ; i ++ ) { String a = map . get ( i ) ; result += a + " ▁ " ; } return result ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (while_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))))) (expression_statement (assignment_expression left: (identifier) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier))))) (while_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (string_literal))) right: (identifier))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (string_literal))) right: (string_literal))))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (string_literal)))))) (return_statement (identifier))))