File tree Expand file tree Collapse file tree
src/test/java/com/java/programs Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import java .io .*;
2+ import java .util .*;
3+
4+ // Input example as below.
5+ /*
6+ 2
7+ Hacker
8+ Rank
9+ */
10+ // Output as below.
11+ /*
12+ Hce akr
13+ Rn ak
14+ */
15+
16+
17+ public class Solution {
18+
19+ public static void main (String [] args ) {
20+ Scanner sc = new Scanner (System .in );
21+ int i = sc .nextInt ();
22+
23+ if (i >= 1 && i <= 10 ){
24+ while (sc .hasNextLine ()){
25+ String S = sc .nextLine ();
26+ char [] ch = S .toCharArray ();
27+ if (ch .length >= 2 && ch .length <= 10000 )
28+ System .out .println (get (S ));
29+ }
30+ }
31+ }
32+
33+ public static String get (String S ) {
34+ StringBuilder a = new StringBuilder ();
35+ StringBuilder b = new StringBuilder ();
36+ char [] ch = S .toCharArray ();
37+ for (int j = 0 ; j < ch .length ; j ++) {
38+ if (j == 0 )
39+ a .append (ch [j ]);
40+ else if (j %2 == 0 )
41+ a .append (ch [j ]);
42+ else
43+ b .append (ch [j ]);
44+ }
45+ return a +" " +b ;
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments