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
`public static Node deleteLastKth(Node list, int k) { Node fast = list; int i = 1; while (fast != null && i < k) { fast = fast.next; ++i; }
if (fast == null) return list; Node slow = list; Node prev = null; while (fast.next != null) { fast = fast.next; prev = slow; slow = slow.next; } if (prev == null) { list = list.next; } else { prev.next = prev.next.next; } return list;
}`
感觉这段代码是删除正序的第k个节点的。不知道我的理解是否正确
The text was updated successfully, but these errors were encountered:
很显然是不正确的
Sorry, something went wrong.
No branches or pull requests
`public static Node deleteLastKth(Node list, int k) {
Node fast = list;
int i = 1;
while (fast != null && i < k) {
fast = fast.next;
++i;
}
}`
感觉这段代码是删除正序的第k个节点的。不知道我的理解是否正确
The text was updated successfully, but these errors were encountered: