import
java.util.*;
public
class
GFG {
public
static
String encryptedString(String str) {
StringBuilder encryptedString =
new
StringBuilder();
encryptedString.append(str.charAt(
0
));
for
(
int
t =
1
; t < str.length(); t++) {
if
(t %
2
==
1
) {
encryptedString.append(str.charAt(t));
}
else
{
encryptedString.insert(
0
, str.charAt(t));
}
}
return
encryptedString.toString();
}
public
static
String decryptedString(String str) {
if
(str.length() %
2
!=
0
) {
StringBuilder decryptedString =
new
StringBuilder();
decryptedString.append(str.charAt(
0
));
for
(
int
t =
1
; t < str.length(); t++) {
decryptedString.append(str.charAt(str.length() -
1
- t));
decryptedString.append(str.charAt(t));
}
return
decryptedString.reverse().toString();
}
else
{
StringBuilder reverseStr =
new
StringBuilder(str).reverse();
StringBuilder decryptedString =
new
StringBuilder();
decryptedString.append(reverseStr.charAt(
0
));
for
(
int
t =
1
; t < reverseStr.length(); t++) {
decryptedString.append(reverseStr.charAt(reverseStr.length() -
1
- t));
decryptedString.append(reverseStr.charAt(t));
}
return
decryptedString.reverse().toString();
}
}
public
static
void
main(String[] args) {
System.out.println(encryptedString(
"geeks"
));
System.out.println(encryptedString(
"geeksforgeeks"
));
System.out.println(encryptedString(
"strive"
));
System.out.println(encryptedString(
"vikaschitturi"
));
System.out.println(encryptedString(
"padmachitturi"
));
System.out.println(encryptedString(
"hackerrank"
));
System.out.println(encryptedString(
"hackerearth"
));
System.out.println(encryptedString(
"codechef"
));
System.out.println(encryptedString(
"IamVikas"
));
System.out.println(encryptedString(
"HelloHowareyou"
));
System.out.println(encryptedString(
"whatareyoudoing"
));
System.out.println(decryptedString(
"segek"
));
System.out.println(decryptedString(
"segosegekfrek"
));
System.out.println(decryptedString(
"vrstie"
));
System.out.println(decryptedString(
"iuthskviacitr"
));
System.out.println(decryptedString(
"iuthadpamcitr"
));
System.out.println(decryptedString(
"nrechakrak"
));
System.out.println(decryptedString(
"hreechakrat"
));
System.out.println(decryptedString(encryptedString(
"IamVikas"
)));
System.out.println(decryptedString(encryptedString(
"HelloHowareyou"
)));
}
}