396. Rotate Function
来源:互联网 发布:淘宝网铁链条鞭 编辑:程序博客网 时间:2024/06/02 04:19
class Solution(object):
def maxRotateFunction(self, A):
"""
:type A: List[int]
:rtype: int
"""
m=0
if len(A) == 0:
return 0
totalSum = sum(A)
lMax = 0
for i in range(len(A)):
lMax += i * A[i]
gMax = lMax
for i in range(len(A)-1, 0, -1):
lMax += (totalSum - A[i] * len(A))
gMax = max(gMax, lMax)
def maxRotateFunction(self, A):
"""
:type A: List[int]
:rtype: int
"""
m=0
if len(A) == 0:
return 0
totalSum = sum(A)
lMax = 0
for i in range(len(A)):
lMax += i * A[i]
gMax = lMax
for i in range(len(A)-1, 0, -1):
lMax += (totalSum - A[i] * len(A))
gMax = max(gMax, lMax)
return gMax
https://discuss.leetcode.com/topic/58360/python-59ms-simple-solution
阅读全文
0 0
- 396. Rotate Function
- 【Leetcode】396. Rotate Function
- [LeetCode]396. Rotate Function
- 396. Rotate Function
- 396. Rotate Function
- LeetCode 396. Rotate Function
- 396. Rotate Function
- 396. Rotate Function
- 396. Rotate Function
- [leetcode]396. Rotate Function
- 396. Rotate Function
- [LeetCode]--396. Rotate Function
- 396. Rotate Function
- leetcode 396. Rotate Function
- [LeetCode] 396. Rotate Function
- 396. Rotate Function
- 396. Rotate Function (python)
- 396. Rotate Function
- Android中应用程序如何获得系统签名权限
- 【C语言常识】函数的重载和重入
- Opencv关于两图像感兴趣区域划分、拼合详解
- iOS .ips(crash)崩溃报告文件分析
- Spring3和java8的冲突
- 396. Rotate Function
- 多线程(1)概述
- QOpenGLTexture II
- 深度学习中几个常用包的参考文档(NumPy,SciPy,Matplotlib,pandas等)
- 基于 maven 的 ssm 项目搭建五:整合 spring
- block
- com.jfinal.core.ActionHandler warn 警告: 404 Action Not Found: /FC01 个人解决方案
- Mac OS下最简单安装ant方法
- Servlet3-异步请求