Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

middle node of linked list

int middleNode(ListNode head) {
    ListNode slow = head
    ListNode fast = head
    while (fast != null and fast.next != null) {
        slow = slow.next
        fast = fast.next.next
    }
    return slow.data
}
Source by afteracademy.com #
 
PREVIOUS NEXT
Tagged: #middle #node #linked #list
ADD COMMENT
Topic
Name
3+3 =