Delete the Middle Node of a Linked List LeetCode solution in Java
1class Solution {2public ListNode deleteMiddle(ListNode head) {3// Base Condition4if (head == null || head.next == null) return null;5// Pointers Created6ListNode fast = head;7ListNode slow = head;8ListNode prev = head;910while (fast != null && fast.next != null) {11prev = slow;12slow = slow.next;13fast = fast.next.next;14}15prev.next = slow.next;16return head;17}18}