-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ10.java
More file actions
26 lines (24 loc) · 677 Bytes
/
Q10.java
File metadata and controls
26 lines (24 loc) · 677 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
public class Q10 {
public static void main(String[] args) {
// System.out.println (pallindrome("jajaja"));
System.out.println (checkpalli("madsm" , 0));
}
private static boolean checkpalli(String b , int a) {
char c = b.charAt (a);
char d = b.charAt (b.length () - a - 1);
if(a >= b.length ()/2){
return true;
}
if(c != d){
return false;
}
return checkpalli (b , a + 1);
}
private static String pallindrome(String a ) {
if(a.isEmpty ()){
return "";
}
char ch = a.charAt (0);
return (a.substring (1) ) + ch;
}
}