iterative solution to this problem . the complexity order of this algorithm in time terms is equals to o n where n is the number of elements in the list . in space terms , the complexity order is o 1 because we are not using any auxiliary data structure to solve this problem . this algorithm is based on know the size of the list , but this part of the algorithm is a problem for the execution time . concode_field_sep PlaceHolder placeHolder concode_field_sep void validateInput concode_elem_sep int getListSize concode_elem_sep ListNode<Integer> get2
ListNode < Integer > function ( ListNode < Integer > arg0 ) { validateInput ( arg0 ) ; int loc0 = getListSize ( arg0 ) ; int loc1 = loc0 % 2 != 0 ? loc0 / 2 : ( loc0 / 2 ) - 1 ; ListNode loc2 = arg0 ; for ( int loc3 = 0 ; loc3 < loc1 ; loc3 ++ ) { loc2 = loc2 . getNext ( ) ; } return loc2 ; }