Tap here to switch tabs
Problem
Submissions

Problem: Count Rotations With Exactly K Equal Adjacent Pairs

Try to solve the Count Rotations With Exactly K Equal Adjacent Pairs problem.

Statement

You are given a string s of length n and an integer k.

A cyclic rotation of s is obtained by shifting the characters of s cyclically by some number of positions.

The score of a string is defined as the number of indices i where 0≤i<n−10 \le i < n - 1 such that the character at index i is equal to the character at index i+1i + 1.

Return the number of cyclic rotations of s that have a score strictly equal to k.

Constraints:

  • 2≤n==2 \le n == s.length ≤100\le 100

  • s only consists of lowercase English letters.

  • 0≤k≤n−10 \le k \le n - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Rotations With Exactly K Equal Adjacent Pairs

Try to solve the Count Rotations With Exactly K Equal Adjacent Pairs problem.

Statement

You are given a string s of length n and an integer k.

A cyclic rotation of s is obtained by shifting the characters of s cyclically by some number of positions.

The score of a string is defined as the number of indices i where 0≤i<n−10 \le i < n - 1 such that the character at index i is equal to the character at index i+1i + 1.

Return the number of cyclic rotations of s that have a score strictly equal to k.

Constraints:

  • 2≤n==2 \le n == s.length ≤100\le 100

  • s only consists of lowercase English letters.

  • 0≤k≤n−10 \le k \le n - 1