Skip to content

Commit 44bcda8

Browse files
committedJan 26, 2020
Add solution #5319
1 parent 8188875 commit 44bcda8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
 
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* 5319. Remove Palindromic Subsequences
3+
* https://leetcode.com/problems/remove-palindromic-subsequences/
4+
* Difficulty: Easy
5+
*
6+
* Given a string s consisting only of letters 'a' and 'b'.
7+
* In a single step you can remove one palindromic subsequence from s.
8+
*
9+
* Return the minimum number of steps to make the given string empty.
10+
* A string is a subsequence of a given string, if it is generated by
11+
* deleting some characters of a given string without changing its order.
12+
*
13+
* A string is called palindrome if is one that reads the same backward
14+
* as well as forward.
15+
*/
16+
17+
/**
18+
* @param {string} s
19+
* @return {number}
20+
*/
21+
var removePalindromeSub = function(s) {
22+
return s.length === 0 ? 0 : (s.split('').reverse().join('') === s ? 1 : 2);
23+
};

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
1318|[Minimum Flips to Make a OR b Equal to c](./1318-minimum-flips-to-make-a-or-b-equal-to-c.js)|Medium|
6464
1323|[Maximum 69 Number](./1323-maximum-69-number.js)|Easy|
6565
1324|[Print Words Vertically](./1324-print-words-vertically.js)|Medium|
66+
5319|[Remove Palindromic Subsequences](./5319-remove-palindromic-subsequences.js)|Easy|
6667
5320|[Filter Restaurants by Vegan-Friendly, Price and Distance](./5320-filter-restaurants-by-vegan-friendly-price-and-distance.js)|Medium|
6768

6869
## License

0 commit comments

Comments
 (0)
Please sign in to comment.