GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/java/409_Longest_Palindrome.java at master · rohit-chandra/leetcode Expand file tree/ Copy path409_Longest_Palindrome.javaMore file actions 16 lines (15 loc) · 411 Bytes / Copy path409_Longest_Palindrome.javaFile metadata and controls16 lines (15 loc) · 411 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 class Solution { // https://leetcode.com/problems/longest-palindrome/solution/ public int longestPalindrome(String s) { int[] count = new int[128]; for (char c: s.toCharArray()) count[c]++; int ans = 0; for (int v: count) { ans += v / 2 * 2; if (ans % 2 == 0 && v % 2 == 1) ans++; } return ans; } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |