Leetcode 396 Rotate Function
来源:互联网 发布:c语言选择题及答案 编辑:程序博客网 时间:2024/04/27 17:39
Given an array of integers A
and let n to be its length.
Assume Bk
to be an array obtained by rotating the array A
k positions clock-wise, we define a "rotation function" F
on A
as follow:
F(k) = 0 * Bk[0] + 1 * Bk[1] + ... + (n-1) * Bk[n-1]
.
Calculate the maximum value of F(0), F(1), ..., F(n-1)
.
Note:
n is guaranteed to be less than 105.
Example:
A = [4, 3, 2, 6]F(0) = (0 * 4) + (1 * 3) + (2 * 2) + (3 * 6) = 0 + 3 + 4 + 18 = 25F(1) = (0 * 6) + (1 * 4) + (2 * 3) + (3 * 2) = 0 + 4 + 6 + 6 = 16F(2) = (0 * 2) + (1 * 6) + (2 * 4) + (3 * 3) = 0 + 6 + 8 + 9 = 23F(3) = (0 * 3) + (1 * 2) + (2 * 6) + (3 * 4) = 0 + 2 + 12 + 12 = 26So the maximum value of F(0), F(1), F(2), F(3) is F(3) = 26.
阅读全文
0 0
- <leetcode>396 Rotate Function
- LeetCode 396 Rotate Function
- Leetcode 396 Rotate Function
- LeetCode #396 - Rotate Function - Easy
- 【Leetcode】396. Rotate Function
- [LeetCode]396. Rotate Function
- [Leetcode] Rotate Function
- LeetCode Rotate Function
- LeetCode : Rotate Function
- LeetCode 396. Rotate Function
- [leetcode]396. Rotate Function
- LeetCode-Rotate Function
- [LeetCode]--396. Rotate Function
- leetcode 396. Rotate Function
- [LeetCode] 396. Rotate Function
- LeetCode 396. Rotate Function
- leetcode之Rotate Function
- 45 leetcode - Rotate Function
- hdu1020Encoding
- 精确计算代码执行时间
- XML与JSON比较,并用AJAX传输XML/JSON数据
- Java集合---LinkedList源码解析
- myeclipse快捷键大全
- Leetcode 396 Rotate Function
- 【Shell】用tar分卷打包压缩
- 全脑思维下的项目管理能力提升
- 用两个栈实现一个队列
- 开窗函数
- FZU1057 之 a^b
- scala基础之提取器extractor
- xv6 System Call
- VC托盘程序的简单实现