package com.dw.algorithmlib;

public class StringAlgorithm {
	
	public boolean isPalindrom(String s) {
		boolean result = true;
		if (s.length() == 0 || s.length() == 1)
			return result;

		for (int i = 0; i <= s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				result = false;
				break;
			}
		}
		return result;
	}
	
	public boolean isPalindromWithDigitalAndChar(String s) {
		boolean result = true;
		
		StringBuilder sb = new StringBuilder();
        
        for(int i=0;i<s.length();i++) {
        	if(Character.isAlphabetic(s.charAt(i)) || Character.isDigit(s.charAt(i))) {
        		sb.append(Character.toLowerCase(s.charAt(i)));
        	}
        }
        
        String pa = sb.toString();
        if(pa.length() == 0 || pa.length() == 1) return result;
        
        for(int i=0;i<=pa.length()/2;i++) {
        	if(pa.charAt(i) != pa.charAt(pa.length() - 1 - i)) {
        		result = false;
        		break;
        	}
        }
        
		return result;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}

@@ -999,16 +999,148 @@
 sult;%0A%09%7D
+%0A%09%0A%09public String reverse(String s) %7B%0A%09%09StringBuilder sb = new StringBuilder();%0A%09%09sb.append(s);%0A%09%09return sb.reverse().toString();%0A%09%7D
 %0A%0A%09publi
@@ -1212,15 +1212,17 @@
 od stub%0A
+%09%09
 %0A%09%7D%0A%0A%7D%0A

add java string reverse