Create a function contentOfTheSecondNode
that returns the content of the second node of the linked list. The argument of the function is aHead
. It is the pointer that contains the address of the head. If the function receives the nullptr
, then the function should return -777
. However, if the function receives a pointer to the head of a real linked list, then it should check whether the list has another node. If it does not, then the function should return -555
. If has at least two nodes, then the function should return the content of the second node. Your code should replace the text // ??? //
below.
long contentOfTheSecondNode(ListNode* aHead){ // ??? // }