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

Fixed issue with lab, had forked old version of lab from reading #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SuperNinjaEv
Copy link

No description provided.

Comment on lines +28 to +39
size() {
let count = 0;
let currentNode = this.head;

while (currentNode) {
// console.log(currentNode);

count++;
currentNode = currentNode.next;
};
return count;
};

Choose a reason for hiding this comment

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

Can you think of a way to have this function run in O(1) instead of O(n)?

solution.js Outdated Show resolved Hide resolved
Comment on lines +156 to +168
containsDuplicates() {
let visited = new Set();
let currentNode = this.head;
while (currentNode) {
if (visited.has(currentNode.data)) {
return true;
}
visited.add(currentNode.data);
currentNode = currentNode.next;
}
return false;
}
}

Choose a reason for hiding this comment

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

Using the this.toArray method can you think of a shorter cleaner way to write this function?

Co-authored-by: Raz Efron <razefron01@gmail.com>
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.

2 participants