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

剑指offer,逆序打印链表,递归方法空指针异常 #960

Open
CodeJavaSheep opened this issue Jul 29, 2020 · 1 comment
Open

剑指offer,逆序打印链表,递归方法空指针异常 #960

CodeJavaSheep opened this issue Jul 29, 2020 · 1 comment

Comments

@CodeJavaSheep
Copy link

@CodeJavaSheep CodeJavaSheep commented Jul 29, 2020

public ArrayList printListFromTailToHead(ListNode listNode) {
ArrayList ret = new ArrayList<>();
if (listNode != null) {
ret.addAll(printListFromTailToHead(listNode.next));//这里listNode.next会出现空指针异常,加一个if(listNode.next) != null)
ret.add(listNode.val);
}
return ret;
}

@CodeJavaSheep
Copy link
Author

@CodeJavaSheep CodeJavaSheep commented Jul 29, 2020

逆序打印链表

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.