# Linked List

## Reversed Linked List

{% embed url="https://www.hackerearth.com/practice/data-structures/linked-list/singly-linked-list/practice-problems/algorithm/reversed-linked-list-01b722df/" %}

```csharp
using System;
using System.Collections;
					
public class Program {
    public static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
	var input = Console.ReadLine().Split(" ");
	Stack evenStack = new Stack();
	for(int i = 0; i < n; i++) {
            var num = Convert.ToInt32(input[i]);
            if(num % 2 == 0) 
                evenStack.Push(num);
            else {
                while(evenStack.Count > 0) {
		    Console.Write(evenStack.Pop() + " ");
	        }
                Console.Write(num + " ");
            }
        }
	while(evenStack.Count > 0) {
            Console.Write(evenStack.Pop() + " ");
        }
    }
}
```
