Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b072556

Browse files
Merge branch 'youngyangyang04:master' into master
2 parents 03e9ef7 + 1ca56dd commit b072556

File tree

169 files changed

+583
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+583
-209
lines changed

‎problems/0001.两数之和.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
## 1. 两数之和
99

10-
[力扣题目链接](https://leetcode-cn.com/problems/two-sum/)
10+
[力扣题目链接](https://leetcode.cn/problems/two-sum/)
1111

1212
给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。
1313

‎problems/0005.最长回文子串.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# 5.最长回文子串
1010

11-
[力扣题目链接](https://leetcode-cn.com/problems/longest-palindromic-substring/)
11+
[力扣题目链接](https://leetcode.cn/problems/longest-palindromic-substring/)
1212

1313
给你一个字符串 s,找到 s 中最长的回文子串。
1414

‎problems/0015.三数之和.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
# 第15题. 三数之和
1212

13-
[力扣题目链接](https://leetcode-cn.com/problems/3sum/)
13+
[力扣题目链接](https://leetcode.cn/problems/3sum/)
1414

1515
给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有满足条件且不重复的三元组。
1616

‎problems/0017.电话号码的字母组合.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# 17.电话号码的字母组合
99

10-
[力扣题目链接](https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/)
10+
[力扣题目链接](https://leetcode.cn/problems/letter-combinations-of-a-phone-number/)
1111

1212
给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。
1313

‎problems/0018.四数之和.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
# 第18题. 四数之和
1212

13-
[力扣题目链接](https://leetcode-cn.com/problems/4sum/)
13+
[力扣题目链接](https://leetcode.cn/problems/4sum/)
1414

1515
题意:给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,使得 a + b + c + d 的值与 target 相等?找出所有满足条件且不重复的四元组。
1616

‎problems/0019.删除链表的倒数第N个节点.md‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
## 19.删除链表的倒数第N个节点
1111

12-
[力扣题目链接](https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/)
12+
[力扣题目链接](https://leetcode.cn/problems/remove-nth-node-from-end-of-list/)
1313

1414
给你一个链表,删除链表的倒数第 n 个结点,并且返回链表的头结点。
1515

@@ -289,6 +289,30 @@ func removeNthFromEnd(_ head: ListNode?, _ n: Int) -> ListNode? {
289289
return dummyHead.next
290290
}
291291
```
292+
293+
294+
PHP:
295+
```php
296+
function removeNthFromEnd($head, $n) {
297+
// 设置虚拟头节点
298+
$dummyHead = new ListNode();
299+
$dummyHead->next = $head;
300+
301+
$slow = $fast = $dummyHead;
302+
while($n-- && $fast != null){
303+
$fast = $fast->next;
304+
}
305+
// fast 再走一步,让 slow 指向删除节点的上一个节点
306+
$fast = $fast->next;
307+
while ($fast != NULL) {
308+
$fast = $fast->next;
309+
$slow = $slow->next;
310+
}
311+
$slow->next = $slow->next->next;
312+
return $dummyHead->next;
313+
}
314+
```
315+
292316
Scala:
293317
```scala
294318
object Solution {

‎problems/0020.有效的括号.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
# 20. 有效的括号
1212

13-
[力扣题目链接](https://leetcode-cn.com/problems/valid-parentheses/)
13+
[力扣题目链接](https://leetcode.cn/problems/valid-parentheses/)
1414

1515
给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。
1616

‎problems/0024.两两交换链表中的节点.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
## 24. 两两交换链表中的节点
99

10-
[力扣题目链接](https://leetcode-cn.com/problems/swap-nodes-in-pairs/)
10+
[力扣题目链接](https://leetcode.cn/problems/swap-nodes-in-pairs/)
1111

1212
给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。
1313

‎problems/0027.移除元素.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
## 27. 移除元素
99

10-
[力扣题目链接](https://leetcode-cn.com/problems/remove-element/)
10+
[力扣题目链接](https://leetcode.cn/problems/remove-element/)
1111

1212
给你一个数组 nums 和一个值 val,你需要 原地 移除所有数值等于 val 的元素,并返回移除后数组的新长度。
1313

‎problems/0028.实现strStr.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
# 28. 实现 strStr()
1111

12-
[力扣题目链接](https://leetcode-cn.com/problems/implement-strstr/)
12+
[力扣题目链接](https://leetcode.cn/problems/implement-strstr/)
1313

1414
实现 strStr() 函数。
1515

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /