Max Consecutive Ones in Binary Array

🔥 Day 13/100 Days Coding Challenge ✅ Problem Solved: Max Consecutive Ones Today’s problem was about finding the maximum number of consecutive 1’s in a binary array. 💡 Key Idea: Traverse the array, count consecutive 1’s, and reset when encountering 0 — while tracking the maximum count. 🧠 What I Learned: Importance of maintaining a running count Using Math.max() efficiently Solving problems in O(n) time with constant space 💻 Approach: Initialize count = 0, max = 0 Loop through array If element is 1 → increment count Else → reset count Update max at each step Consistency is key 🔑 — small steps every day lead to big results! #Day13 #100DaysOfCode #Java #DSA #CodingChallenge #LeetCode #ProblemSolving

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories