Valid Palindrome LeetCode
Approach 1: Using Inbuilt reverse() Function on StringBuffer Object. s=s.replaceAll("[^a-zA-Z0-9]", "");//replace all non alphanumeric characters with empty string. s=s.toLowerCase(); StringBuffer sb=new StringBuffer(); sb.append(s); String s2=sb.reverse().toString(); if(s.equals(s2)){ return true; } else{ return false; } Time: O(N) [As do swapping of characters by iterating up to half of the length of given string length.][LeetCode Time: 23 ms beats 30.26% ] Space: O(Length of String)[LeetCode Memory: 40MB beats 32.77%] ========================================================================= Approach 2: ...