문제 난이도 : Easy
문제 유형 : Data Structures - Linked Lists
문제 설명 간략 :
Singly-linked list를 거꾸로 출력하라.
제약사항
- 1 <= n <= 1000
- 1 <= list[i] <= 1000, where list[i] is the ith element of the linked list
자바 풀이
/*
* Complete the 'reversePrint' function below.
*
* The function accepts INTEGER_SINGLY_LINKED_LIST llist as parameter.
*/
/*
* For your reference:
*
* SinglyLinkedListNode {
* int data;
* SinglyLinkedListNode next;
* }
*
*/
public static void reversePrint(SinglyLinkedListNode llist) {
if(llist == null) {
return;
}
reversePrint(llist.next);
System.out.println(llist.data);
}
출처