diff --git a/problems/面试题02.07.链表相交.md b/problems/面试题02.07.链表相交.md index dda7f2ad..75e03116 100644 --- a/problems/面试题02.07.链表相交.md +++ b/problems/面试题02.07.链表相交.md @@ -101,8 +101,8 @@ public: ## 其他语言版本 +Java: -### Java ```Java public class Solution { public ListNode getIntersectionNode(ListNode headA, ListNode headB) { @@ -150,9 +150,13 @@ public class Solution { } ``` -### Python + +Python: + ```python + (版本一)求长度,同时出发 + class Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: lenA, lenB = 0, 0 @@ -255,6 +259,7 @@ class Solution: # self.val = x # self.next = None + class Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: # 处理边缘情况 @@ -274,7 +279,8 @@ class Solution: # 如果相交,指针将位于交点节点,如果没有交点,值为None return pointerA ``` -### Go + +Go: ```go func getIntersectionNode(headA, headB *ListNode) *ListNode { @@ -335,7 +341,7 @@ func getIntersectionNode(headA, headB *ListNode) *ListNode { } ``` -### javaScript +JavaScript: ```js var getListLen = function(head) { @@ -447,6 +453,7 @@ ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) { ``` Scala: + ```scala object Solution { def getIntersectionNode(headA: ListNode, headB: ListNode): ListNode = {