Skip to content

Commit 2f2346c

Browse files
committed
Added C++ Solution
1 parent 9e21b9e commit 2f2346c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Java/soln-dynamic-programming-problems/longest-palindromic-subsequence.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
References-
55
https://www.geeksforgeeks.org/longest-palindromic-subsequence-dp-12/
66
https://leetcode.com/problems/longest-palindromic-subsequence/
7-
*/
7+
8+
NOTE: Variation of Longest Common Subsequence
9+
*/
10+
11+
//------------------------------------------------------------------------------
12+
//Tabulation Approach
813

914
import java.util.*;
1015
import java.lang.*;

Java/soln-string-problems/palindrome-longest-build.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ public int longestPalindrome(String s) {
1414
HashMap<Character,Integer> map=new HashMap<>();
1515
char[] char_s=s.toCharArray();
1616

17-
for(char ch:char_s){
17+
for(char ch:char_s)
1818
map.put(ch,map.getOrDefault(ch,0)+1);
19-
}
2019

2120
int flag=0;
2221
for(char key:map.keySet()){
23-
if(map.get(key)%2!=0){
22+
if(map.get(key)%2!=0)
2423
flag++;
25-
}
2624
}
2725
return flag>0?s.length()-flag+1:s.length();
2826
}

0 commit comments

Comments
 (0)