Problem: https://leetcode.com/problems/consecu...
Code Link: https://github.com/skystone1000/LeetCode
December Challenge 2021 - Day 13
1446. Consecutive Characters
TIMESTAMPS
0:00 Intro
0:19 Question
1:18 Approach 1 - Brute force
2:25 Approach 1 - Code
3:27 Approach 2 - One Pass
4:31 Approach 2 - Code
6:22 Approach 3 - Sliding Window
7:45 Approach 3 - Code
9:45 Output
Approach
We need to calculate the power of string which in short is the max substring that has same character so a simple and optimized way would be to do a single traversal and maintain 2 variables one for power(which would be our ans) and the other for iteration max(currMax) and the increment currMax when we have the same character and update the power when we encounter a diff character and reset currMax
🔗 Social Media 🔗
📝 LinkedIn: / adityamahajan123
📂 GitHub: https://github.com/skystone1000/
📸 Instagram: / skystone1000
👑 Chess.com : https://www.chess.com/member/skystone...
⭐ Discord Server: / discord
⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡
⭐ Tags ⭐
- Aditya Mahajan
⭐ Hashtags ⭐
#leetcode #1306Leetcode