implemented CycleDetectionII code in LinkedList
Hey maintainers, I've implemented the code for getting the starting node of cycle in a linked list which i think will be useful for understanding of cycle-type-questions. I've also added the tests to check the correctness. It'll be my first open source contribution and also in Hacktoberfest. Hoping a success :)
Changes:
- [ ] Added a code to get the starting node of cycle in LinkedList
Checklist:
I've read the CONTRIBUTING.md file and also checked the testcases using npm as asked to. This pr is all my own work.
Dear maintainers, Thanks for the feedback !! I appreciate you taking the time to look over the code and provide suggestions. I've made the following changes as suggested:
- Added comments explaining the logic
- you're absolutely right that using f and s is redundant when I already have fast and slow pointers
- removed the redundant comments in tests
- In my opinion, for this problem the key focus is detecting the cycle start node, so I wanted to keep that logic upfront in detectCycleNode(). Defining the helper lengthCycle() function below separates it out from the main detection logic. That said, I'm open to rearranging if you feel strongly that defining lengthCycle() first improves the overall structure.
Let me know! And thanks again for the review :)
I wanted to reach out to let you know that while attempting my first contribution to this open source project, I ran into some issues with git push. (That's why so many commits) After doing some research, I was able to resolve the issues and successfully contribute my changes. I realize this may not have been the most elegant first contribution, and I wanted to apologize in advance if I caused any inconvenience. As a first time contributor, I was still learning the contribution workflow.
Hey maintainers, I'd be really glad if you could review this ;)
Dear maintainers, Thanks for reviewing again! I appreciate you taking this much time to provide suggestions for a beginner like me. I've made few minor changes to the code and also explained my thought process and addressed to your valuable reviews. Please let me know if anything is required. And am really sorry for the delays as i was occupied with campus interviews and exams. (am looking for my first internship)
Please let me know if there's anything more that needs to be addressed. Fingers crossed for the merge ;)
Sorry for the long delay. I simplified the code a bit and renamed some variables. I hope you're fine with this, otherwise feel free to complain :)
LGTM!
Sorry for the long delay. I simplified the code a bit and renamed some variables. I hope you're fine with this, otherwise feel free to complain :)
LGTM!
LGTM too! Thanks for simplifying things, and no complaints here :))