Find the middle element in a singly linked list. Tell the complexity of your solution. First solution:

Question:

Find the middle element in a singly linked list. Tell the complexity of your solution.

First solution: Find the length of linked list. Then find the middle element and return it.

Second solution: Use two pointer one will move fast and another will move slow, make sure you handle border case properly. (Even length and odd length linked list cases.)

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: