Week 3
Week 3
1.https://leetcode.com/problems/design-browser-history/
# A class to represent a node in a doubly linked list
class Node:
def __init__(self, url: str):
# The previous and next nodes in the list
self.prev = None
self.next = None
# The URL represented by this node
self.url = url
2. https://leetcode.com/problems/stamping-the-sequence/
class Solution:
def maxSubarraySumCircular(self, nums: List[int]) -> int:
def kadane(arr :List[int])->int :
max_ends_here = max_so_far = arr[0]
for el in arr[1:]:
max_ends_here = max(el, max_ends_here + el)
max_so_far = max(max_ends_here, max_so_far )
return max_so_far
max_kadane = kadane(nums) #step1
totsum = sum(nums) #step2