Skip to content

Commit ebfbe7d

Browse files
committed
2330 solved.
1 parent c635289 commit ebfbe7d

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
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.22)
2+
project(cpp_2330)
3+
4+
set(CMAKE_CXX_STANDARD 14)
5+
6+
add_executable(cpp_2330 main.cpp)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// Source : https://leetcode.com/problems/valid-palindrome-iv/
2+
/// Author : liuyubobobo
3+
/// Time : 2022-07-10
4+
5+
#include <iostream>
6+
7+
using namespace std;
8+
9+
10+
/// Ad-Hoc
11+
/// Time Complexity: O(n)
12+
/// Space Complexity: O(1)
13+
class Solution {
14+
public:
15+
bool makePalindrome(string s) {
16+
17+
int n = s.size(), res = 0;
18+
for(int i = 0, j = n - 1; i < j; i ++, j --)
19+
res += s[i] != s[j];
20+
21+
return res <= 2;
22+
}
23+
};
24+
25+
26+
int main() {
27+
28+
return 0;
29+
}

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2176,7 +2176,7 @@ email: [liuyubobobo@gmail.com](mailto:liuyubobobo@gmail.com)
21762176
| 2327 | [Number of People Aware of a Secret](https://leetcode.com/problems/number-of-people-aware-of-a-secret/) | [] | [C++](2001-2500/2327-Number-of-People-Aware-of-a-Secret/cpp-2327/) | | |
21772177
| 2328 | [Number of Increasing Paths in a Grid](https://leetcode.com/problems/number-of-increasing-paths-in-a-grid/) | [] | [C++](2001-2500/2328-Number-of-Increasing-Paths-in-a-Grid/cpp-2328/) | | |
21782178
| 2329 | Database Problem: [Link](https://github.com/liuyubobobo/Play-Leetcode-Database/) | - | - | - | - |
2179-
| | | | | | |
2179+
| 2330 | [Valid Palindrome IV](https://leetcode.com/problems/valid-palindrome-iv/) | [] | [C++](2001-2500/2330-Valid-Palindrome-IV/cpp-2330/) | | |
21802180
| 2331 | [Evaluate Boolean Binary Tree](https://leetcode.com/problems/evaluate-boolean-binary-tree/) | [] | [C++](2001-2500/2331-Evaluate-Boolean-Binary-Tree/cpp-2331/) | | |
21812181
| | | | | | |
21822182
| 2333 | [Minimum Sum of Squared Difference](https://leetcode.com/problems/minimum-sum-of-squared-difference/) | [] | [C++](2001-2500/2333-Minimum-Sum-of-Squared-Difference/cpp-2333/) | | |

0 commit comments

Comments
 (0)