β Suspense String
Suspense String medium Time Limit: 2 sec Memory Limit: 128000 kB
```java
import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework
// don't change the name of this class
// you can add inner classes if needed
class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in) ;
int tc = sc.nextInt() ;
while(tc-->0){
int n = sc.nextInt() ;
sc.nextLine();
String str = sc.nextLine() ;
String newstr = "", ans = "", n1 = '1' + "" ,n0 = '0' + "" ;
for(int i=0; i<n+1/2; i++){
newstr = newstr + str.charAt(i) ;
newstr = newstr + str.charAt(n-1-i) ;
}
for(int i = 0; i<n; i++){
if(i%2 == 0){
if(newstr.charAt(i) == '0')
ans = n0+ans ;
else
ans = ans+n1 ;
}
else{
if(newstr.charAt(i) == '0')
ans = ans+n0 ;
else
ans = n1+ans ;
}
}
System.out.println(ans);
}
}
}
```Last updated