第29524题 单选题
在Python实现的单链表中,已知节点类定义如下,若要在非尾节点p之后插入值为x的新节点,以下代码片段正确的是?

单链表节点类定义:

class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

现有头节点为head的非空单链表,p为链表中存在的非尾节点。

{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析