add: desc [cpp]
This commit is contained in:
parent
bbe37d1fa7
commit
7ffcac9824
|
|
@ -2,6 +2,14 @@
|
|||
#include <functional>
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* 2024. Maximize the Confusion of an Exam
|
||||
* A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecutive questions with the same answer (multiple trues or multiple falses in a row).
|
||||
* You are given a string answerKey, where answerKey[i] is the original answer to the ith question. In addition, you are given an integer k, the maximum number of times you may perform the following operation:
|
||||
* Change the answer key for any question to 'T' or 'F' (i.e., set answerKey[i] to 'T' or 'F').
|
||||
* Return the maximum number of consecutive 'T's or 'F's in the answer key after performing the operation at most k times.
|
||||
*/
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
static int maxConsecutiveAnswers(const std::string& answerKey, int k) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,13 @@
|
|||
#include <vector>
|
||||
#include <bitset>
|
||||
|
||||
/**
|
||||
* 287. Find the Duplicate Number
|
||||
* Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.
|
||||
* There is only one repeated number in nums, return this repeated number.
|
||||
* You must solve the problem without modifying the array nums and uses only constant extra space.
|
||||
*/
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
static int findDuplicate(const std::vector<int>& nums) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue