halfrost / LeetCode-Go

✅ Solutions to LeetCode by Go, 100% test coverage, runtime beats 100% / LeetCode 题解

Home Page:https://books.halfrost.com/leetcode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0148. Sort List中的middleNode函数边界处理

pench3r opened this issue · comments

https://github.com/halfrost/LeetCode-Go/blob/master/leetcode/0148.Sort-List/148.%20Sort%20List.go

	for p2.Next != nil && p2.Next.Next != nil {
		p1 = p1.Next
		p2 = p2.Next.Next
	}

需要增加边界判断p2.Next != nil.

@pench3r 您好,在这个 for 循环的条件里面已经有判断 p2.Next != nil 了。

僵住了,自己犯了低级错误了。