Skip to content

Comments

485. Max Consecutive Ones.cpp#4

Merged
Subhosjx merged 1 commit intoSubhosjx:mainfrom
SjxSubham:patch-2
Oct 27, 2025
Merged

485. Max Consecutive Ones.cpp#4
Subhosjx merged 1 commit intoSubhosjx:mainfrom
SjxSubham:patch-2

Conversation

@SjxSubham
Copy link
Contributor

Intuition

This is vary easy question you can solve it easily.
let suppose,
nums = [1,1,0,1,1,1]
so maximum consecutive once is 3
go through the approach

Approach

  1. init two variable one for store the max value and one for count the once

  2. iterate the nums array
    if nums[i] = 1 then increase the count by 1 and store the maximun value between nums[i] and max
    But if we encounted by 0 then set the count variable to 0

  3. return the max value

@Subhosjx Subhosjx merged commit 8afce06 into Subhosjx:main Oct 27, 2025
1 check passed
@github-actions
Copy link

🎉 Congrats on getting your PR merged in, @SjxSubham! 🙌🏼

Thanks for your contribution every effort helps improve the project.

Looking forward to seeing more from you! 🥳✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants