diff --git a/README.md b/README.md deleted file mode 100644 index 7c3b229..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Algorithms 2019-2020 Python LEETCODE - -Check branches for information. \ No newline at end of file diff --git a/linked-list.md b/linked-list.md new file mode 100644 index 0000000..842583b --- /dev/null +++ b/linked-list.md @@ -0,0 +1,32 @@ +# Linked list + ++ [Intersection of Two Linked Lists](#intersection-of-two-linked-lists) + +## Intersection of Two Linked Lists + +https://leetcode.com/problems/intersection-of-two-linked-lists/ + +```python +# Definition for singly-linked list. +# class ListNode(object): +# def __init__(self, x): +# self.val = x +# self.next = None +class Solution(object): + def getIntersectionNode(self, _headA, _headB): + """ + :type _headA, _headB: ListNode + :rtype: ListNode + """ + headA, headB = _headA, _headB + if not (headA and headB): + return None + + nodeA, nodeB = headA, headB + while nodeA is not nodeB: + nodeA = headB if not nodeA else nodeA.next + nodeB = headA if not nodeB else nodeB.next + + return nodeA + +``` \ No newline at end of file