Hey, I am so delighted to say that I was able to take the next step in my competitive programming journey. I started from knowing nothing about linked lists and have now begun learning some of the tougher concepts. After covering the basics, I moved on to more complicated topics. I’ve learned about linked lists and tackled a few related questions over the past few days. Today, I focused on Dojo-related questions, as I need them for my upcoming dojo this week. I made a plan with that in mind.
On Thursday, I again faced a collection of linked list and string-type problems: Reverse Linked List II, Linked List Cycle, Find All Anagrams in a String.
Reverse Linked List II would be a standard reversal of a portion of the list; given two positions, it could reverse that portion of the list. That would require really careful pointer manipulation to get the portion separated and correctly reconnected. It's a bit tricky, but breaking it into smaller pieces makes it easy.
Linked List Cycle involved a given linked list in detecting if a given linked list had a cycle. I employed the use of Floyd's Cycle Detection Algorithm (commonly referred to as the tortoise-and-hare algorithm), creating an application that relied on the two pointers with the speeds being different, if there would be any kind of convergence for the two, and they eventually met; thus proving a cycle. The exercise with pointer behavior and finding cycles proved useful in this problem.
Lastly, I solved Find All Anagrams in a String. This problem required finding all starting indices of substrings in a given string that were anagrams of a target string. Using the sliding window technique and frequency arrays, I efficiently identified the anagrams. This problem tested my ability to work with strings and optimize solutions for large inputs.
Top comments (0)