1
0

Q2609.h 518 B

12345678910111213141516171819202122232425
  1. //
  2. // Created by 李洋 on 2023/11/8.
  3. //
  4. #ifndef LEECODE_C_Q2609_H
  5. #define LEECODE_C_Q2609_H
  6. #include <string>
  7. #include <vector>
  8. #include <stack>
  9. using namespace std;
  10. int findTheLongestBalancedSubstring(string s) {
  11. int n = s.size(), idx = 0, ans = 0;
  12. while (idx < n) {
  13. int a = 0, b = 0;
  14. while (idx < n && s[idx] == '0' && ++a >= 0) idx++;
  15. while (idx < n && s[idx] == '1' && ++b >= 0) idx++;
  16. ans = max(ans, min(a, b) * 2);
  17. }
  18. return ans;
  19. }
  20. #endif //LEECODE_C_Q2609_H
备用站点 当前处于降级运行的备用站点,仅供应急访问,数据和功能可能不是最新。