This commit is contained in:
2025-09-15 21:12:04 +08:00
commit 3f58f483ff
144 changed files with 5298 additions and 0 deletions

25
23/11/Q2609.h Normal file
View File

@@ -0,0 +1,25 @@
//
// Created by 李洋 on 2023/11/8.
//
#ifndef LEECODE_C_Q2609_H
#define LEECODE_C_Q2609_H
#include <string>
#include <vector>
#include <stack>
using namespace std;
int findTheLongestBalancedSubstring(string s) {
int n = s.size(), idx = 0, ans = 0;
while (idx < n) {
int a = 0, b = 0;
while (idx < n && s[idx] == '0' && ++a >= 0) idx++;
while (idx < n && s[idx] == '1' && ++b >= 0) idx++;
ans = max(ans, min(a, b) * 2);
}
return ans;
}
#endif //LEECODE_C_Q2609_H