Skip to content

Practice Count the Number of Substrings With Dominant Ones

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3234
LeetCode Problem

Count the Number of Substrings With Dominant Ones

Problem Statement

You are given a binary string s. Return the number of substrings with dominant ones. A string has dominant ones if the number of ones in the string is greater than or equal to the square of the number of zeros in the string.

Source: Count the Number of Substrings With Dominant Ones on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "00011"
Output
5

# Example 2

Input
s = "101101"
Output
16

Constraints

1 <= s.length <= 4 * 10^4
s consists only of characters '0' and '1'.

Related LeetCode Problems

Practice more problems similar to Count the Number of Substrings With Dominant Ones.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.