-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrot.py
More file actions
40 lines (34 loc) · 889 Bytes
/
rot.py
File metadata and controls
40 lines (34 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Pendig....
class Solution(object):
def maxRotateFunction(self, A):
:type A: List[int]
:rtype: int
"""
"""
# Time Limit Exceeded
# Rotate Array
def rotate(A):
n = len(A)
if n == 1:
return [A[0]]
else:
return [A[n-1]]+A[:n-1]
# Result Calculation
def result_calc(A):
n = len(A)
ans = 0
for i in range(n):
ans += i*A[i]
return ans
# Maximum value tracking
maxi = -60000000000000
n = len(A)
if n == 0:
return 0
for i in range(n):
A = rotate(A)
value = result_calc(A)
if value > maxi:
maxi = value
return maxi
"""