Tap here to switch tabs
Problem
Submissions

Problem: Number of Distinct Binary Strings After Operations

Try to solve the Number of Distinct Binary Strings After Applying Operations problem.

Statement

You are given a binary string s and a positive integer k.

In a single operation, you can select any substring of s of length k and invert all of its bits, replacing every ′0′'0' with a ′1′'1' and every ′1′'1' with a ′0′'0'. This operation can be applied any number of times.

Return the number of distinct binary strings that can be produced. Since the result can be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq k ≤\leq s.length ≤105\leq 10^5

  • s[i] is either ′0′'0' or ′1′'1'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Distinct Binary Strings After Operations

Try to solve the Number of Distinct Binary Strings After Applying Operations problem.

Statement

You are given a binary string s and a positive integer k.

In a single operation, you can select any substring of s of length k and invert all of its bits, replacing every ′0′'0' with a ′1′'1' and every ′1′'1' with a ′0′'0'. This operation can be applied any number of times.

Return the number of distinct binary strings that can be produced. Since the result can be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq k ≤\leq s.length ≤105\leq 10^5

  • s[i] is either ′0′'0' or ′1′'1'.