Time complexity of the optimal algorithm to interchange the $m^{th}$ and $n^{th}$ elements of a singly Linked List is

@Tesla!! But are we changing the links of these two nodes of linked lists or just the value of variables inside them?!

@shraddha priya you can change link as well as value it doesn't matter

Say m < n.

Hence, it takes O(n) time, when n>m

So, Option B.

Option A is also correct.

https://stackoverflow.com/questions/19455942/understanding-time-complexity-of-omaxm-n