-
Notifications
You must be signed in to change notification settings - Fork 23
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
finished #1
base: main
Are you sure you want to change the base?
finished #1
Conversation
this.head = head | ||
}; | ||
|
||
size() { |
There was a problem hiding this comment.
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)?
}; | ||
|
||
isEmpty() { | ||
let count = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a way to write this in one line and O(n) run time
} | ||
|
||
containsDuplicates() { | ||
let visited = new Set(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a set you could compare the length of the set to the size of the linked list for shorter, cleaner code
No description provided.