Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f1bdebe

Browse files
committed
增加面试题
1 parent 5829130 commit f1bdebe

File tree

4 files changed

+142
-54
lines changed

4 files changed

+142
-54
lines changed

.idea/workspace.xml

+71-54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LinkedList/No876.java

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package LinkedList;
2+
3+
/**
4+
* @author tujietg
5+
* @date 6/11/20 9:38 AM
6+
*/
7+
public class No876 {
8+
public ListNode middleNode(ListNode head) {
9+
ListNode slow = head, fast = head;
10+
while (fast != null && fast.next != null) {
11+
slow = slow.next;
12+
fast = fast.next.next;
13+
}
14+
return slow;
15+
}
16+
}

LinkedList/Nom24.java

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package LinkedList;
2+
3+
/**
4+
* @author tujietg
5+
* @date 6/11/20 2:08 PM
6+
*/
7+
public class Nom24 {
8+
public ListNode swapPairs(ListNode head) {
9+
if (head == null || head.next == null) {
10+
return head;
11+
}
12+
ListNode oneNode = head;
13+
ListNode twoNode = head.next;
14+
15+
oneNode.next = swapPairs(twoNode.next);
16+
twoNode.next = oneNode;
17+
return twoNode;
18+
}
19+
}

LinkedList/Nom27.java

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package LinkedList;
2+
3+
/**
4+
* @author tujietg
5+
* @date 6/11/20 11:37 AM
6+
*/
7+
public class Nom27 {
8+
/**
9+
* Definition for singly-linked list.
10+
* public class ListNode {
11+
* int val;
12+
* ListNode next;
13+
* ListNode(int x) {
14+
* val = x;
15+
* next = null;
16+
* }
17+
* }
18+
*/
19+
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
20+
ListNode a1 = headA, b1 = headB;
21+
while (a1 != b1) {
22+
if (a1 == null) {
23+
a1 = headB;
24+
} else {
25+
a1 = a1.next;
26+
}
27+
28+
if (b1 == null) {
29+
b1 = headA;
30+
} else {
31+
b1 = b1.next;
32+
}
33+
}
34+
return a1;
35+
}
36+
}

0 commit comments

Comments
 (0)