- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
485. Max Consecutive Ones | Best Linear Solution Explained in C Plus
Title: 485. Max Consecutive Ones | Best Linear Solution Explained in C Plus Plus | LeetCode Solution
Description:
In this video, I solve LeetCode 485 Max Consecutive Ones using an efficient linear traversal approach in C Plus Plus.
Problem Explanation
Optimized Approach
Dry Run
Time and Space Complexity
Clean STL Based Code
Approach:
We traverse the array and count consecutive ones.
Whenever we encounter zero, we reset the count.
At every step, we maintain the maximum consecutive count found so far.
Algorithm:
1. Initialize count equals 0 and maxi equals 0
2. Traverse the array
3. If current element equals 1 increment count
4. Update maximum count using max function
5. If current element equals 0 reset count to 0
Time Complexity O of N
Space Complexity O of 1
GitHub
https://github.com/atulXdev
LeetCode Profile
https://leetcode.com/u/atul_singh_cg/
LinkedIn
https://www.linkedin.com/in/atul-singh-987b0b394/
leetcode dsa cpp maxconsecutiveones arrays codinginterview striverdsa leetcode485 datastructures algorithms
Видео 485. Max Consecutive Ones | Best Linear Solution Explained in C Plus канала Atul Singh
Description:
In this video, I solve LeetCode 485 Max Consecutive Ones using an efficient linear traversal approach in C Plus Plus.
Problem Explanation
Optimized Approach
Dry Run
Time and Space Complexity
Clean STL Based Code
Approach:
We traverse the array and count consecutive ones.
Whenever we encounter zero, we reset the count.
At every step, we maintain the maximum consecutive count found so far.
Algorithm:
1. Initialize count equals 0 and maxi equals 0
2. Traverse the array
3. If current element equals 1 increment count
4. Update maximum count using max function
5. If current element equals 0 reset count to 0
Time Complexity O of N
Space Complexity O of 1
GitHub
https://github.com/atulXdev
LeetCode Profile
https://leetcode.com/u/atul_singh_cg/
https://www.linkedin.com/in/atul-singh-987b0b394/
leetcode dsa cpp maxconsecutiveones arrays codinginterview striverdsa leetcode485 datastructures algorithms
Видео 485. Max Consecutive Ones | Best Linear Solution Explained in C Plus канала Atul Singh
Комментарии отсутствуют
Информация о видео
12 мая 2026 г. 20:34:22
00:03:45
Другие видео канала




















