Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved sublist search algorithm #123

Closed
wants to merge 1 commit into from

Conversation

saurabh12nxf
Copy link
Contributor

This PR adds the implementation of the sublist search algorithm using linked lists in Java. The algorithm determines if one linked list (list2) is a sublist of another linked list (list1) by sequentially comparing nodes using a sliding window approach.
the strategy that i have used:
Node Class: Defined to represent elements in a linked list, encapsulating data and a reference to the next node.
Sublist Search Function: Implemented to check if list2 is a sublist of list1. The function traverses list1 and compares segments of list1 with list2.
Helper Function: Added to create a linked list from an array for easier testing and demonstration.

Main Method: Provided example usage to demonstrate the sublist search algorithm.

Testing:
Created example linked lists and verified that the function correctly identifies sublists.

Tested edge cases including empty lists and lists of different lengths.

Results
Successfully identified list2 as a sublist of list1 in various test cases.

Passed all edge case scenarios.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing in the project for the first time, don't stop yourself and keep on contributing, your pull request will be reviewed soon

@saurabh12nxf saurabh12nxf closed this by deleting the head repository Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant