79736551

Date: 2025-08-15 15:13:09
Score: 2
Natty:
Report link

for this question imo we can do something like gnome sort/ sorting by reversal like for example we have this linked list 1 -> 2 -> 3 -> 4 so i start with 1 and change its head pointers head to 1 like so in this way the subsequent steps would look something like this 2 -> 1 -> 3 -> 4, 2 -> 3 -> 1 -> 4, 2 -> 3 -> 4 -> 1.
This way we can achieve reversal of a singly linked list using n(n-1)/2 pointer reassignments, because at each position we are doing i operation where i is the index from 1 to n

Reasons:
  • Blacklisted phrase (1): this link
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: olivia xd