π One-stop destination for all your technical interview Preparation π
class Solution {
public:
void deleteNode(ListNode* node){
node->val = node->next->val;
node->next = node->next->next;
}
};
letβs analyze why this problem isnβt a good interview question.
The whole point of asking any candidates a linked list problem is to test if the candidates think about edge cases, including:
1. Dereferencing Null Pointer, usually targeting tail pointer
2. When given Head is None
3. When there are duplications in the list
This question specifically mentioned all the above edge cases and extracted them out for you Someone who can solve this problem might not even think of all the edge cases, which can backfire on them in real interview settings