MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / palin

Method palin

Java/Leetcode/Leetcode125.java:9–27  ·  view source on GitHub ↗
(String s)

Source from the content-addressed store, hash-verified

7 }
8
9 static boolean palin(String s) {
10 StringBuilder s1 = new StringBuilder();
11 for (int i = 0; i < s.length(); i++) {
12 char ch = Character.toLowerCase(s.charAt(i));
13 if (ch >= 97 && ch <= 122 || ch >= 48 && ch <= 57) {
14 s1.append(ch);
15 }
16 }
17
18 StringBuilder s2 = new StringBuilder(s1);
19
20 reverse(s2);
21
22 if (s1.toString().equals(s2.toString())) {
23 return true;
24 } else {
25 return false;
26 }
27 }
28
29 static void reverse(StringBuilder s){
30 int start=0,end=s.length()-1;

Callers 1

mainMethod · 0.95

Calls 3

reverseMethod · 0.95
lengthMethod · 0.80
equalsMethod · 0.80

Tested by

no test coverage detected