Skip to content

Commit e95b51b

Browse files
committed
1332 solved.
1 parent 9472963 commit e95b51b

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(cpp_1332)
3+
4+
set(CMAKE_CXX_STANDARD 14)
5+
6+
add_executable(cpp_1332 main.cpp)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/// Source : https://leetcode.com/problems/remove-palindromic-subsequences/
2+
/// Author : liuyubobobo
3+
/// Time : 2020-02-21
4+
5+
#include <iostream>
6+
7+
using namespace std;
8+
9+
10+
/// Mathematics
11+
/// Time Complexity: O(n)
12+
/// Space Complexity: O(1)
13+
class Solution {
14+
public:
15+
int removePalindromeSub(string s) {
16+
17+
if(s == "") return 0;
18+
return isPalindrome(s) ? 1 : 2;
19+
}
20+
21+
private:
22+
bool isPalindrome(const string& s){
23+
24+
for(int i = 0, j = s.size() - 1; i < j; i ++, j --)
25+
if(s[i] != s[j]) return false;
26+
return true;
27+
}
28+
};
29+
30+
31+
int main() {
32+
33+
return 0;
34+
}

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,8 @@ email: [liuyubobobo@gmail.com](mailto:liuyubobobo@gmail.com)
912912
| 1318 | [Minimum Flips to Make a OR b Equal to c](https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c/) | [] | [C++](1318-Minimum-Flips-to-Make-a-OR-b-Equal-to-c/cpp-1318/) | | |
913913
| 1319 | [Number of Operations to Make Network Connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected/) | [] | [C++](1319-Number-of-Operations-to-Make-Network-Connected/cpp-1319/) | | |
914914
| | | | | | |
915+
| 1332 | [Remove Palindromic Subsequences](https://leetcode.com/problems/remove-palindromic-subsequences/) | [solution](https://leetcode.com/problems/remove-palindromic-subsequences/solution/) | [C++](1332-Remove-Palindromic-Subsequences/cpp-1332/) | | |
916+
| | | | | | |
915917
| 1337 | [The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/) | [] | [C++](1337-The-K-Weakest-Rows-in-a-Matrix/cpp-1337/) | | |
916918
| 1338 | [Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half/) | [] | [C++](1338-Reduce-Array-Size-to-The-Half/cpp-1338/) | | |
917919
| 1339 | [Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree/) | [] | [C++](1339-Maximum-Product-of-Splitted-Binary-Tree/cpp-1339/) | | |

0 commit comments

Comments
 (0)