Method:
. Use two pointers in a loop
. One pointer will jump one node, where as the other pointer will jump 2 nodes.
. When the fast pointer reaches the end, the slow pointer will be at the middle.
Subscribe to:
Post Comments (Atom)
Design and implementation of interesting data structures and algorithms. You may find it useful either in your computer science course curriculum or in technical interviews of companies like Microsoft, Amazon, Google, Yahoo, Sun, Oracle etc
No comments:
Post a Comment