You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public ListNode insertionSortList(ListNode head) { /// head will stay where it is
ListNode start = new ListNode(-1);
start.next = head;
ListNode prev = start;
ListNode curr = head;
while (curr != null) {
ListNode poss = start;
while (poss.next != curr && poss.next.val <= curr.val) { // insert as far back as possible to avoid infinite loop {ex. two equivalent values are swapped, and when curr moves ahead one, it reaches the one it just switched with}