Flip
Автор: Code with Alisha
Загружено: 27 сент. 2021 г.
Просмотров: 15 216 просмотров
Timestamps:
0:00 Reading the problem
2:30 Explaining intuition
3:30 Kadane Algorithm
6:00 Kadane Code and Dry Run
10:30 Example dry run
13:02 Code CPP
Input Format
First and only argument is a string A.
Output Format
Return an array of integers denoting the answer.
Example Input
Input 1:
A = "010"
Input 2:
A = "111"
Example Output
Output 1:
[1, 1]
Output 2:
[]
Example Explanation
Explanation 1:
A = "010"
Pair of [L, R] | Final string
___________|_________
[1 1] | "110"
[1 2] | "100"
[1 3] | "101"
[2 2] | "000"
[2 3] | "001"
We see that two pairs [1, 1] and [1, 3] give same number of 1s in final string. So, we return [1, 1].
Explanation 2:
No operation can give us more than three 1s in final string. So, we return empty array [].

Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: