为什么本地编译器行,这里却所越界了呢? 求解答
class Solution {
public:
ListNode* FindKthToTail(ListNode* pListHead, unsigned int k)
{
std::vectornode_list;
while(pListHead)
{
node_list.push_back(pListHead);
pListHead = pListHead ->next;
}
int len = node_list.size();
return node_list[len - k];
}
};
class Solution {
public:
ListNode* FindKthToTail(ListNode* pListHead, unsigned int k)
{
std::vector
while(pListHead)
{
node_list.push_back(pListHead);
pListHead = pListHead ->next;
}
int len = node_list.size();
return node_list[len - k];
}
};
「求助大佬帮看看这道算法题吧!」输入一个链表,输出该链表中倒数第k个结点。
https://gw-c.nowcoder.com/api/sparta/jump/link?link=https%3A%2F%2Fwww.nowcoder.com%2FquestionTerminal%2F529d3ae5a407492994ad2a246518148a
全部评论
相关推荐