Tap here to switch tabs
Problem
Submissions

Problem: Count Good Cyclic Rotations

med
30 min
Try to solve the Count Good Cyclic Rotations problem.

Statement

Given an integer array nums of even length n.

A cyclic rotation of nums is defined as shifting all elements to the left or right cyclically. A cyclic rotation is considered good if the sum of its first n / 22 elements is strictly greater than the sum of its last n / 22 elements.

Return the total number of good cyclic rotations of nums.

Constraints:

  • 2≤n==2 \leq n == nums.length ≤105\leq 10^5

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

  • n is even.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Good Cyclic Rotations

med
30 min
Try to solve the Count Good Cyclic Rotations problem.

Statement

Given an integer array nums of even length n.

A cyclic rotation of nums is defined as shifting all elements to the left or right cyclically. A cyclic rotation is considered good if the sum of its first n / 22 elements is strictly greater than the sum of its last n / 22 elements.

Return the total number of good cyclic rotations of nums.

Constraints:

  • 2≤n==2 \leq n == nums.length ≤105\leq 10^5

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

  • n is even.