Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

题解 148:删除重复函数 #82

Closed
beihai0xff opened this issue Dec 11, 2020 · 1 comment
Closed

题解 148:删除重复函数 #82

beihai0xff opened this issue Dec 11, 2020 · 1 comment

Comments

@beihai0xff
Copy link

题解 148 中出现了这样一段重复的函数,删掉mergeTwoLists148就好了。sortList函数调用的函数名称也要对应改一下。

func mergeTwoLists148(l1 *ListNode, l2 *ListNode) *ListNode {
	if l1 == nil {
		return l2
	}
	if l2 == nil {
		return l1
	}
	if l1.Val < l2.Val {
		l1.Next = mergeTwoLists(l1.Next, l2)
		return l1
	}
	l2.Next = mergeTwoLists(l1, l2.Next)
	return l2
}

func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode {
	if l1 == nil {
		return l2
	}
	if l2 == nil {
		return l1
	}
	if l1.Val < l2.Val {
		l1.Next = mergeTwoLists(l1.Next, l2)
		return l1
	}
	l2.Next = mergeTwoLists(l1, l2.Next)
	return l2
}
@halfrost
Copy link
Owner

@wingsxdu 感谢你的提醒。已经修复了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants