1019. Next Greater Node In Linked List

Stack Solution ```python Definition for singly-linked list. class ListNode: def init(self, val=0, next=None): self.val = val self.next = next class Solution: def nextLargerNodes(self, head: ListNode) -> List[int]: “”” tc O(N) sc O(N) idx 0 1 2 3 4 5 6 7 val 1,7,5,1,9,2,5,1 ans 7 9 9 9 0 5... [Read More]

1856. Maximum Subarray Min-Product

Solution: Presum + mono Stack class Solution: def maxSumMinProduct(self, A: List[int]) -> int: """ tc O(N) sc O(N) main idea: assume any A[i] is smallest, extend its max range to get largest presum 1. get left bound: for A[i], within i:0, the first index j so that A[j] < A[i]... [Read More]
Tags: Array Stack