#include <leetcode.h>
◆ maxConsecutiveAnswers()
int leetcode::maximize_the_confusion_of_an_exam::Solution::maxConsecutiveAnswers |
( |
string |
answerKey, |
|
|
int |
k |
|
) |
| |
|
static |
在文件 leetcode.cpp 第 5214 行定义.
5215 if(answerKey.length() == 1) {
5218 vector<int> t_count(answerKey.length());
5219 vector<int> f_count(answerKey.length());
5222 for(
int i = 0; i < t_count.size(); i++) {
5223 if(answerKey[i] ==
'T') {
5228 t_count[i] = t_current;
5229 f_count[i] = f_current;
5232 int r = answerKey.size();
5233 auto check = [&answerKey, &t_count, &f_count, &k](
int len) ->
bool {
5234 for(
int i = 0; i + len <= answerKey.length(); i++) {
5235 int tc = t_count[i + len - 1] - (i - 1 >= 0 ? t_count[i - 1] : 0);
5236 int fc = f_count[i + len - 1] - (i - 1 >= 0 ? f_count[i - 1] : 0);
5237 if(min(tc, fc) <= k) {
5250 const int mid = (l + r) / 2;
被这些函数引用 leetcode::maximize_the_confusion_of_an_exam::TEST().
该类的文档由以下文件生成: