Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Substrings With Dominant Ones

Try to solve the Count the Number of Substrings With Dominant Ones problem.

Statement

You are given a binary string s.

A substring is said to have dominant ones if the total count of '1's in the substring is greater than or equal to the square of the total count of '0's in that substring.

Return the total number of substrings of s that have dominant ones.

Constraints:

  • 1≤1 \leq s.length ≤4×104\leq 4 \times 10^4

  • s consists only of characters '0' and '1'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Substrings With Dominant Ones

Try to solve the Count the Number of Substrings With Dominant Ones problem.

Statement

You are given a binary string s.

A substring is said to have dominant ones if the total count of '1's in the substring is greater than or equal to the square of the total count of '0's in that substring.

Return the total number of substrings of s that have dominant ones.

Constraints:

  • 1≤1 \leq s.length ≤4×104\leq 4 \times 10^4

  • s consists only of characters '0' and '1'.