Let x be a node in SLL. Write a C++ function to delete the data in this node. Following this deletion, the number of nodes in the list is one less than before the deletion. Your function must run for O(1).
But you won't learn anything by being given the answer. The trick is to think outside the box a little bit. Naively deleting a node from a single linked list is O(n) because you have to find the previous node for unlinking. So what can you do to avoid needing the previous node?
Consider this: Swap the data with the next node, then delete the next node. This is what I mean by thinking outside the box.
Thinking through these types of problems on a simple data structure like a linked list is invaluable for when you move on to more complex data structures. In particular, this swap and delete technique is very handy with trees. But the reason I'm directing you rather than simply gaving away answers is because if you only know the specific technique for that data structure, variations of it for other data structures don't stand out as readily.