Skip to content

Commit 11e0c38

Browse files
committed
Time: 4 ms (100%), Space: 17.8 MB (65.28%) - LeetHub
1 parent d68d369 commit 11e0c38

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# time complexity: O(nlogn)
2+
# space complexity: O(n)
3+
from typing import List
4+
5+
6+
class Solution:
7+
def maximizeExpressionOfThree(self, nums: List[int]) -> int:
8+
nums.sort()
9+
return nums[-1] + nums[-2] - nums[0]
10+
11+
12+
nums = [1, 4, 2, 5]
13+
print(Solution().maximizeExpressionOfThree(nums))
14+
nums = [-2, 0, 5, -2, 4]
15+
print(Solution().maximizeExpressionOfThree(nums))

0 commit comments

Comments
 (0)