Category: two_pointers
-
LeetCode 19: Remove Nth Node From End of List
link As long as we know the previous and the next nodes of the to-be-deleted node, we can update the pointers to delete the node. Say there are total nodes in the list. Say the -th node from the end is the -th node from the head. Then, and . From the head, if we…
-
LeetCode 15: 3Sum
link Time: , space: . Sorting helps in two ways: Time: , space: sorting’s worst-case, . Instead of sorting, we could use one set to de-duplicate first elements and a second set to to find the (second, third) pair in a single scan. Time: , space: .