We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
剑指offer23题这里,三个函数传入的是同一个head,这样有问题吧,cloneNodes(head);执行完,head就不是头节点了,再去执行 connectNodes(head);就错了。应给给一个临时变量cur,每个方法执行前赋值为head, 然后方法调用传入cur. /** * 实现函复制一个复杂链表。在复杂链表中,每个结点除了有一个next字段指向下一个结点外, * 还有一个sibling字段指向链表中的任意结点或者NULL * * @param head 链表表头结点 * @return 复制结点的头结点 */ public static ComplexListNode clone(ComplexListNode head) { // 如果链表为空就直接返回空 if (head == null) { return null; }
// 先复制结点 cloneNodes(head); // 再链接sibling字段 connectNodes(head); // 将整个链表拆分,返回复制链表的头结点 return reconnectNodes(head); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
剑指offer23题这里,三个函数传入的是同一个head,这样有问题吧,cloneNodes(head);执行完,head就不是头节点了,再去执行 connectNodes(head);就错了。应给给一个临时变量cur,每个方法执行前赋值为head, 然后方法调用传入cur.
/**
* 实现函复制一个复杂链表。在复杂链表中,每个结点除了有一个next字段指向下一个结点外,
* 还有一个sibling字段指向链表中的任意结点或者NULL
*
* @param head 链表表头结点
* @return 复制结点的头结点
*/
public static ComplexListNode clone(ComplexListNode head) {
// 如果链表为空就直接返回空
if (head == null) {
return null;
}
The text was updated successfully, but these errors were encountered: