• + 1 comment

    same here in C#:

    **

    public static void ReversePrint(Node head) {
       if (head != null) {
         var tempNode = head;
         var counter = 1;
         while (tempNode.Next != null) {
           ++counter;
           tempNode = tempNode.Next;
         }
         int[] arr = new int[counter];
    
         counter = 1;
         tempNode = head;
         while (tempNode.Next != null) {
           arr[counter - 1] = tempNode.Data;
           ++counter;
           tempNode = tempNode.Next;
         }
         arr[counter-1] = tempNode.Data;
         for (int i = arr.Length - 1; i >= 0; --i) {
           Console.WriteLine(arr[i]);
         }
       }
    
     }
    

    **

    • + 0 comments

      if (head != null) { ReversePrint(head.Next); Console.WriteLine(head.Data); }