Problem · String
Maximum Positive Feedback
Learn this problemProblem statement
The other quesiton in the same batch was posted on our Discord server oa-update channel.
The TikTok Content creator's videos receives feedback from viewers over time, represented as a binary string, videoFeedback:
The creator wants to improve a video's overall positive reception by strategically targeting a portion of the video for editing or improvement. Here's the strategy:
The objective is to maximize the total positive feedback(1s) for the entire video after performing this operation.
Note: The operation must be performed only once.
Function
getMaxPositiveFeedback(videoFeedback: String) → int
Complete the function getMaxPositiveFeedback in the editor.
getMaxPositiveFeedback has the following parameter:
- string videoFeedback: a binary string representing the feedback on a video, where 1 represents positive feedback and 0 represents negative reaction
Examples
Example 1
videoFeedback = "100110"return = 5Given videoFeedback_size = 6 and videoFeedback = "100110",
The interval i = 4 to j = 5 can be selected as the unchanged segment of the video.
Flipping the bits from index 1 to 3 transforms the string from "100110" to "011110".
Next, flipping the bit at index 6 (i.e., the last bit) changes the string from "011110" to "011111".
As this string contains 5 ones, the output should be 5. There are no intervals that produce an output greater than 5.
More Tiktok problems
- Can Reach the Exit with TeleportsOA · Seen Jul 2026
- Check Monotonic TriplesOA · Seen Jul 2026
- Shift Every K-th ConsonantOA · Seen Jul 2026
- Count Access Code PairsOA · Seen Jul 2026
- Count Key ChangesOA · Seen Jul 2026
- Sort Matrix BordersOA · Seen Jul 2026
- Travel Distance on ScootersOA · Seen Jul 2026
- Validate 3x3 Digit WindowsOA · Seen Jul 2026