Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- # @param A : list of integers
- # @return an integer
- def largestRectangleArea(self, A):
- max_sum = 0
- if len(A) == 0:
- return None
- if len(A) == 1:
- return A[0]
- for i in range(len(A)):
- count = 1
- round_sum = 0
- while i+count <= len(A)-1:
- sum = min(A[i:i+count+1]) * (count+1)
- count += 1
- if sum > round_sum:
- round_sum = sum
- if sum < round_sum:
- break
- if round_sum > max_sum:
- max_sum = round_sum
- return max_sum
- s = Solution()
- #list = [ 90, 58, 69, 70, 82, 100, 13, 57, 47, 18 ]
- list = [ 65, 19, 8, 39, 14, 21, 83, 87, 95, 11, 14, 58, 11, 90,
- 34, 96, 34, 62, 96, 38, 58, 57, 12, 78, 57, 60, 7, 58,
- 56, 49, 36, 67, 69, 30, 74, 46, 97, 62, 47, 42, 43, 98,
- 60, 32, 39, 75, 69, 28, 35, 52, 89, 78, 4, 26, 65, 21,
- 39, 89, 87, 69, 48, 60, 6, 21, 5, 98, 52, 59 ]
- #list = [51,33]
- #list = [ 6, 2, 5, 4, 5, 1, 6 ]
- #10
- print(s.largestRectangleArea(list))
- Your function returned the following :
- 570
- The expected returned value :
- 700
Advertisement
Add Comment
Please, Sign In to add comment