Minimum Number of Operations to Make Array Continuous - LeetCode 2009 - Python

preview_player
Показать описание
Solution, explanation, and complexity analysis for LeetCode 2009, the problem of the day for October 10th, in Python.

Problem Description:

Code with updated O(1) space solution:
Рекомендации по теме
Комментарии
Автор

Update: I was able to improve on the solution in the video by keeping track of duplicates in the sliding window to have it be O(1) space. I attached the solution in the Code in the description for the video. It's very similar to the one in the video but now every time we find a duplicate we increase the duplicate count, and every time we get rid of one we decrease the count. Our window length is r - l + 1 - duplicates. Also cool that this one beats 100% of all solutions on LeetCode in terms of space I think so just wanted to include that one if anyone is interested.

Alpha-Code
join shbcf.ru