Skip to content

Commit 3512460

Browse files
committed
palindrom string
1 parent 9d705e0 commit 3512460

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.dev.stringmanpulations;
2+
3+
public class PalindromStrings {
4+
5+
public static boolean isPalindrom(String str){
6+
int left = 0 , right = str.length() -1;
7+
while (left < right){
8+
if (str.charAt(left) != str.charAt(right))
9+
return false;
10+
right --;
11+
left ++;
12+
}
13+
return true;
14+
}
15+
16+
public static void main(String[] args) {
17+
18+
String word = "level";
19+
20+
boolean palindrom = isPalindrom(word);
21+
System.out.println("palindrom = " + palindrom);
22+
}
23+
}

0 commit comments

Comments
 (0)