mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-12 21:50:49 +08:00
@ -101,8 +101,8 @@ public:
|
|||||||
|
|
||||||
## 其他语言版本
|
## 其他语言版本
|
||||||
|
|
||||||
|
Java:
|
||||||
|
|
||||||
### Java
|
|
||||||
```Java
|
```Java
|
||||||
public class Solution {
|
public class Solution {
|
||||||
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
|
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
|
||||||
@ -150,9 +150,13 @@ public class Solution {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Python
|
|
||||||
|
Python:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
(版本一)求长度,同时出发
|
(版本一)求长度,同时出发
|
||||||
|
|
||||||
class Solution:
|
class Solution:
|
||||||
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
|
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
|
||||||
lenA, lenB = 0, 0
|
lenA, lenB = 0, 0
|
||||||
@ -255,6 +259,7 @@ class Solution:
|
|||||||
# self.val = x
|
# self.val = x
|
||||||
# self.next = None
|
# self.next = None
|
||||||
|
|
||||||
|
|
||||||
class Solution:
|
class Solution:
|
||||||
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
|
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
|
||||||
# 处理边缘情况
|
# 处理边缘情况
|
||||||
@ -274,7 +279,8 @@ class Solution:
|
|||||||
# 如果相交,指针将位于交点节点,如果没有交点,值为None
|
# 如果相交,指针将位于交点节点,如果没有交点,值为None
|
||||||
return pointerA
|
return pointerA
|
||||||
```
|
```
|
||||||
### Go
|
|
||||||
|
Go:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func getIntersectionNode(headA, headB *ListNode) *ListNode {
|
func getIntersectionNode(headA, headB *ListNode) *ListNode {
|
||||||
@ -335,7 +341,7 @@ func getIntersectionNode(headA, headB *ListNode) *ListNode {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### javaScript
|
JavaScript:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var getListLen = function(head) {
|
var getListLen = function(head) {
|
||||||
@ -447,6 +453,7 @@ ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Scala:
|
Scala:
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
object Solution {
|
object Solution {
|
||||||
def getIntersectionNode(headA: ListNode, headB: ListNode): ListNode = {
|
def getIntersectionNode(headA: ListNode, headB: ListNode): ListNode = {
|
||||||
|
Reference in New Issue
Block a user