Skip to content

Instantly share code, notes, and snippets.

@kshitijvarshne1
Created June 20, 2021 15:12
Show Gist options
  • Save kshitijvarshne1/feeef72310404c9dfba046cbbe1671a3 to your computer and use it in GitHub Desktop.
Save kshitijvarshne1/feeef72310404c9dfba046cbbe1671a3 to your computer and use it in GitHub Desktop.
/* 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