-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSame_String.java
More file actions
34 lines (29 loc) · 814 Bytes
/
Copy pathSame_String.java
File metadata and controls
34 lines (29 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.company;
import java.io.IOException;
import java.util.Scanner;
public class Same_String {
public static void main(String args[]) throws IOException {
//write your code here
Scanner s = new Scanner(System.in);
int t = s.nextInt();
s.nextLine();
while (t-- > 0) {
String s1 = s.nextLine();
String s2 = "";
string(s1, 0, s2);
}
}
private static void string(String s1, int n, String s2) {
if (n == s1.length()) {
if(s1.equals(s2)){
System.out.println("Yes");
}
else {
System.out.println("No");
}
return;
}
s2 = s2 + s1.charAt((s1.length() - n) - 1);
string(s1, n + 1, s2);
}
}