092.Reverse Linked List II Posted on 2017-09-24 | In LeetCode Solution 1: accepted 3ms 93%Well, it shouldn’t be this long. Can we optimize it? 12345678910111213141516171819202122232425262728293031public ListNode reverseBetween(ListNode head, int m, int n) { ListNode dummy = new ListNode(0); dummy.next = head; head = dummy; for (int i = 1; i < m; i++) { head = head.next; } ListNode cur = head.next; ListNode rev = null; // reversed part ListNode tail = null; int count = n - m; for (int i = m; i <= n; i++) { ListNode temp = cur.next; if (rev != null) { cur.next = rev; rev = cur; } else { rev = cur; tail = cur; rev.next = null; } cur = temp; count--; if (i >= n) { tail.next = cur; head.next = rev; } } return dummy.next;}