- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Maximum Number of Words Found in Sentences | LeetCode Easy | String Logic | C++
🔹 Problem: Maximum Number of Words Found in Sentences (LeetCode)
In this video, we solve a beginner-friendly string observation problem.
The task is to find the maximum number of words present in a sentence.
---
🔹 Key Observation:
If words are separated by single spaces:
Words =
Spaces + 1
So instead of splitting strings,
we simply count spaces.
---
🔹 Approach:
For every sentence:
1. Count spaces
2. Add 1
3. Update maximum answer
---
🔹 Dry Run Example:
Sentence:
"alice and bob love leetcode"
Spaces:
4
Words:
5
Another sentence:
"this is great thanks very much"
Words:
6
Maximum Answer:
6
---
🔹 Time Complexity:
O(total characters)
🔹 Space Complexity:
O(1)
---
🔗 GitHub: https://github.com/DhruvOzha85
🔗 LeetCode Profile: https://leetcode.com/u/DhruvOzha/
🔗 LinkedIn: https://www.linkedin.com/in/dhruv-ozha-bb378639b/
---
📌 Notes:
- Great beginner string problem
- Important observation-based logic
- Efficient without split()
---
🔥 Follow for more daily DSA problem solutions!
#leetcode #strings #wordcount #dsa #codinginterview #cplusplus #programming #algorithms #coding #leetcodeeasy #tech #softwareengineer #placements #codingpractice
maximum number of words found in sentences, string problems, word counting, leetcode easy, dsa problems, coding interview questions, c++ dsa, algorithms, programming, interview prep, coding practice
Видео Maximum Number of Words Found in Sentences | LeetCode Easy | String Logic | C++ канала Dhruv Ozha
In this video, we solve a beginner-friendly string observation problem.
The task is to find the maximum number of words present in a sentence.
---
🔹 Key Observation:
If words are separated by single spaces:
Words =
Spaces + 1
So instead of splitting strings,
we simply count spaces.
---
🔹 Approach:
For every sentence:
1. Count spaces
2. Add 1
3. Update maximum answer
---
🔹 Dry Run Example:
Sentence:
"alice and bob love leetcode"
Spaces:
4
Words:
5
Another sentence:
"this is great thanks very much"
Words:
6
Maximum Answer:
6
---
🔹 Time Complexity:
O(total characters)
🔹 Space Complexity:
O(1)
---
🔗 GitHub: https://github.com/DhruvOzha85
🔗 LeetCode Profile: https://leetcode.com/u/DhruvOzha/
🔗 LinkedIn: https://www.linkedin.com/in/dhruv-ozha-bb378639b/
---
📌 Notes:
- Great beginner string problem
- Important observation-based logic
- Efficient without split()
---
🔥 Follow for more daily DSA problem solutions!
#leetcode #strings #wordcount #dsa #codinginterview #cplusplus #programming #algorithms #coding #leetcodeeasy #tech #softwareengineer #placements #codingpractice
maximum number of words found in sentences, string problems, word counting, leetcode easy, dsa problems, coding interview questions, c++ dsa, algorithms, programming, interview prep, coding practice
Видео Maximum Number of Words Found in Sentences | LeetCode Easy | String Logic | C++ канала Dhruv Ozha
Комментарии отсутствуют
Информация о видео
25 мая 2026 г. 9:48:02
00:05:08
Другие видео канала





















