Skip to content

Commit fe3fb6e

Browse files
Merge pull request PawanJaiswal08#14 from Afraz0Khan/dev
lc_11_sol
2 parents 9eb17a3 + b6a661b commit fe3fb6e

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

11.contain-most-water.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def maxArea(height: list[int]) -> int:
2+
area = 0
3+
n = len(height) -1
4+
j = 0
5+
6+
while j < n:
7+
w = n-j
8+
area = max(area, min(height[j], height[n])*w)
9+
if height[j] <= height[n]:
10+
j+=1
11+
else:
12+
n-=1
13+
return area
14+

19.remove-nth-from-end-of-list.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
3+
class ListNode:
4+
def __init__(self, val=0, next=None):
5+
self.val = val
6+
self.next = next
7+
8+
9+
10+
11+
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
12+
dummy = ListNode(0, head)
13+
current = dummy
14+
second = head
15+
16+
while n > 0 and second:
17+
second = second.next
18+
n-=1
19+
20+
while second:
21+
second = second.next
22+
current = current.next
23+
current.next = current.next.next
24+
25+
return dummy.next

0 commit comments

Comments
 (0)