Created
June 20, 2021 15:12
-
-
Save kshitijvarshne1/feeef72310404c9dfba046cbbe1671a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Created by IntelliJ IDEA. | |
* Author: Kshitij Varshney (kshitijvarshne1) | |
* Date: 10-May-21 | |
* Time: 6:44 PM | |
* File: aaaa.java | |
*/ | |
import java.util.ArrayList; | |
import java.util.Scanner; | |
public class aaaa { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int t = sc.nextInt(); | |
while (t-- > 0) { | |
String s = sc.next(); | |
StringBuilder sample = new StringBuilder(); | |
sample.append(s); | |
ArrayList<Integer> p = new ArrayList<>(); | |
ArrayList<Integer> antip = new ArrayList<>(); | |
for (int i = 0; i < s.length(); i++) { | |
if (s.charAt(i) == sample.charAt(s.length() - 1 - i)) { | |
p.add(i + 1); | |
} else { | |
antip.add(i + 1); | |
} | |
} | |
System.out.println(p.size() + " " + antip.size()); | |
for (Integer integer : p) { | |
System.out.print(integer + " "); | |
} | |
System.out.println(); | |
for (Integer integer : antip) { | |
System.out.print(integer + " "); | |
} | |
System.out.println(); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment