You are viewing a single comment's thread. Return to all comments →
Even shorter:
static void reversePrint(SinglyLinkedListNode head) { if(head.next!=null) reversePrint(head.next); System.out.println(head.data); }
This will throw a NullPointerException when given head is null. So you might want to handle that.
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Print in Reverse
You are viewing a single comment's thread. Return to all comments →
Even shorter:
This will throw a NullPointerException when given head is null. So you might want to handle that.