Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4178883

Browse files
committedApr 2, 2025·
Optimize daily
1 parent ceebb5f commit 4178883

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
 
File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def maximumTripletValue(self, nums: List[int]) -> int:
3+
max_n, max_dif, output = 0, 0, 0
4+
for n in nums :
5+
output = max(output, max_dif * n)
6+
max_n = max(max_n, n)
7+
max_dif = max(max_dif, max_n - n)
8+
return output
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def maximumTripletValue(self, nums: List[int]) -> int:
3+
max_n, max_dif, output = 0, 0, 0
4+
return max([
5+
output := (max(output, max_dif * n),
6+
max_n := max(max_n, n),
7+
max_dif := max(max_dif, max_n - n))[0]
8+
for n in nums
9+
])

0 commit comments

Comments
 (0)
Please sign in to comment.