Skip to content

add Solution for 3739.Count Sub Arrays With Majority Elements II#110

Merged
hoangdao3 merged 1 commit into
mainfrom
add-3739-count-subarrays-with-majority-elements-ii
Jun 26, 2026
Merged

add Solution for 3739.Count Sub Arrays With Majority Elements II#110
hoangdao3 merged 1 commit into
mainfrom
add-3739-count-subarrays-with-majority-elements-ii

Conversation

@lyxuansang91

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the repository’s write-up and index entry for LeetCode 3739. Count Subarrays With Majority Element II, including an accompanying problem description document and a new internal “add-solution” skill guide under .claude/.

Changes:

  • Added a new Hard solution write-up for problem 3739 (with Go + Rust implementations and explanation).
  • Added a description.md for problem 3739 with examples and constraints.
  • Updated README.md totals and Hard table to include the new problem link; added an .claude skill document to codify add-solution conventions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
README.md Updates overall solution counts and adds the 3739 entry to the Hard index table.
Hard/3739.Count-Subarrays-With-Majority-Element-II/solution.md Adds the algorithm explanation and Go/Rust reference implementations.
Hard/3739.Count-Subarrays-With-Majority-Element-II/description.md Adds the problem statement, examples, and constraints in repo format.
.claude/skills/add-solution/SKILL.md Adds internal guidance for consistently adding future solutions and updating the index.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
## Solutions index

Total: **159** problems with at least one solution file.
Total: **160** problems with at least one solution file.
Comment on lines +49 to +67
func countMajoritySubarrays(nums []int, target int) int64 {
n := len(nums)
prefix := make([]int, 2*n+1)
prefix[n] = 1
count := n
ans, sum := 0, 0
for _, num := range nums {
if num == target {
sum += prefix[count]
count++
} else {
count--
sum -= prefix[count]
}
prefix[count]++
ans += sum
}
return int64(ans)
}
@hoangdao3
hoangdao3 merged commit 4b13d30 into main Jun 26, 2026
1 check passed
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.

3 participants