"we can use two pointer + set like maintain i,j and also insert jth character to set like while set size is equal to our window j-i+1 then maximize our answer and increase jth pointer till last index"
Kishor J. - "we can use two pointer + set like maintain i,j and also insert jth character to set like while set size is equal to our window j-i+1 then maximize our answer and increase jth pointer till last index"See full answer
"class ListNode:
def init(self, val=0, next=None):
self.val = val
self.next = next
def has_cycle(head: ListNode) -> bool:
slow, fast = head, head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow == fast:
return True
return False
debug your code below
node1 = ListNode(1)
node2 = ListNode(2)
node3 = ListNode(3)
node4 = ListNode(4)
creates a linked list with a cycle: 1 -> 2 -> 3 -> 4"
Anonymous Roadrunner - "class ListNode:
def init(self, val=0, next=None):
self.val = val
self.next = next
def has_cycle(head: ListNode) -> bool:
slow, fast = head, head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow == fast:
return True
return False
debug your code below
node1 = ListNode(1)
node2 = ListNode(2)
node3 = ListNode(3)
node4 = ListNode(4)
creates a linked list with a cycle: 1 -> 2 -> 3 -> 4"See full answer
"Make current as root.
2 while current is not null,
if p and q are less than current,
go left.
If p and q are greater than current,
go right.
else return current.
return null"
Vaibhav D. - "Make current as root.
2 while current is not null,
if p and q are less than current,
go left.
If p and q are greater than current,
go right.
else return current.
return null"See full answer
Data Engineer
Data Structures & Algorithms
+4 more
🧠Want an expert answer to a question? Saving questions lets us know what content to make next.