Home >Backend Development >Python Tutorial >This week experience
Hi, Folks! This is my second week in practicing data structure problems. Today, I solved three problems related to concept of linked list. Compared to the first week, my second week is much better because my understanding skills improved significantly. Experience and practice really matter in problem solving.
As, I was solving linked list related problems : Intersection of two linked lists, Remove nth node from end of list, and Reverse nodes in k-group. I found each problem had its unique challenge.
Intersection of two linked problem can be solved with a simple logic using two pointers. By traversing through both the linked lists with these pointers, we can determine if they meet at common node. If they do, we simply return pointer
Remove nth node this problem is straight logic. We can create a dummy Node to help manage linked list and use two pointers, fast and slow By moving both the pointers towards end of list, when fast pointer reaches end of the list, the slow pointer will be at node just before the nth node that needs to be removed. In this way we can remove nth node from given linked list.
Reverse nodes in k-group in this problem we create dummy node and start iterating to find the kth node. Once the kth node is found, we can reverse the linked list in groups of k nodes. This way, I was able to complete the problem.
I hope my experience will be helpful.
The above is the detailed content of This week experience. For more information, please follow other related articles on the PHP Chinese website!