Tap here to switch tabs
Problem
Submissions

Problem: Count Subarrays With Majority Element II

Try to solve the Count Subarrays With Majority Element II problem.

Statement

Given an integer array nums and an integer target, return the total number of contiguous subarrays in which target is the majority element.

Note: An element is considered the majority element of a subarray if it appears strictly more than half the total number of elements in that subarray.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq target ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Subarrays With Majority Element II

Try to solve the Count Subarrays With Majority Element II problem.

Statement

Given an integer array nums and an integer target, return the total number of contiguous subarrays in which target is the majority element.

Note: An element is considered the majority element of a subarray if it appears strictly more than half the total number of elements in that subarray.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq target ≤109\leq 10^9