#include <leetcode.h>
◆ bestRotation()
int leetcode::smallest_rotation_with_highest_score::Solution::bestRotation |
( |
vector< int > & |
nums | ) |
|
|
static |
在文件 leetcode.cpp 第 4110 行定义.
4111 const int n = nums.size();
4112 vector k_score_diff(n + 1, 0);
4113 for(
int i = 0; i < n; i++) {
4114 const int low = (i + 1) % n;
4115 const int high = (i - nums[i] + n) % n;
4116 k_score_diff[low]++;
4117 k_score_diff[high + 1]--;
4126 for(
int i = 0; i < n; i++) {
4127 score += k_score_diff[i];
4128 if(score > max_score) {
被这些函数引用 leetcode::smallest_rotation_with_highest_score::TEST().
该类的文档由以下文件生成: