Find the mid-point of a singly linked list.
1 -> 2 -> 3 -> 4 -> 5 => 3
1 -> 2 -> 3 -> 4 -> 5 -> 6 => 3 4 (two mid-points in lists with even nodes)
- Time: O(N)
- Space: O(1)
- Complete the required APIs in
question.c
to attempt this question. - Please don't edit the function prototype provided in
question.c
, your . solution might not compile if you do. - If you need hints to solve the problem, look at
hints.c
instead. - When you're done, compile your changes by running:
make all
- Test your code using:
./question < input.txt
or./hints < input.txt
. - The solution is available in
answer.c
(compile using:make answer
) - Get the expected output using:
./answer < input.txt
- Feel free to include any additional header files or define additional functions.
If you have an alternative solution to any of the solutions we've posted that is more optimal or uses a different approach, please email it to us at [email protected]. If it compiles and passes our unit-tests, we will feature your solution and give you credit for it.