Skip to content

Commit 7672018

Browse files
committed
Longest Palindrome
1 parent dd4c3c2 commit 7672018

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/leetcode2018/LongestPalindrome.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ public int longestPalindrome(String s) {
1515
int cont=0;
1616
for(char c: map.keySet()){
1717
if(map.get(c)>1){
18-
cont= cont+ map.get(c);
18+
if(map.get(c)%2==0)
19+
cont= cont+ map.get(c);
20+
else
21+
cont = cont + (map.get(c)-1);
1922
}
2023
}
2124
if(cont<s.toCharArray().length)
2225
cont= cont+1;
2326

24-
return cont;
27+
return cont;
2528
}
2629
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy