Created
November 22, 2020 19:30
-
-
Save abhinavjonnada82/40cb06ff5bb3f333024a03f55a1e71ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*Is palindorme*/ | |
| public boolean isPalindrome(String s) { | |
| char[] = s.toCharArray(); | |
| for (int i = 0, j = c.length - 1; i< j;) { | |
| if (!Character.isLetterOrDigit(c[i])) i++; | |
| else if (!Character.isLetterOrDigit(c[i])) j--; | |
| else if(Character.toLowerCase(c[i++]) != Character.toLowerCase(c[j--])) | |
| return false; | |
| } | |
| return True; | |
| } | |
| /* | |
| isAnagrams | |
| */ | |
| public boolean isAnagram(String s, String t) { | |
| int[] alphabet = new int[26] | |
| for (int i = 0; i < s.length(); i++) | |
| alphabet[s.charAt(i) - 'a']++; | |
| for (int i = 0; i < t.length()l i++) | |
| alphabet[t.charAt(i) - 'a']--; | |
| for (int i : alphabet) | |
| if (i != 0) return false; | |
| return true; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment