diff --git a/cs/reverse-linked-list.cs b/cs/reverse-linked-list.cs new file mode 100644 index 0000000..4b21fc0 --- /dev/null +++ b/cs/reverse-linked-list.cs @@ -0,0 +1,25 @@ +/** + * Definition for singly-linked list. + * public class ListNode { + * public int val; + * public ListNode next; + * public ListNode(int val=0, ListNode next=null) { + * this.val = val; + * this.next = next; + * } + * } + */ +public class Solution { + public ListNode ReverseList(ListNode head) { + ListNode next = null; + + while (head != null) { + var toRight = head.next; + head.next = next; + next = head; + head = toRight; + } + + return next; + } +}