-
-
Notifications
You must be signed in to change notification settings - Fork 21
London | 25-SDC-July | Rihanna Poursoltani | Sprint 1 | Analyse and Refactor Functions #85
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
base: main
Are you sure you want to change the base?
Conversation
LonMcGregor
left a comment
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.
Good work on these, you have found some good optimisations.
There are a few times you identify nested loops as o(n). If you have a nested loop, with the same array looping each time, are you sure it is going to be o(n)?
See also my other comment, there may be better ways to use sets in javascript.
| ]; | ||
| export const findCommonItems = (firstArray, secondArray) => { | ||
| const lookup = new Set(secondArray); | ||
| return [...new Set(firstArray.filter(item => lookup.has(item)))]; |
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.
Given you are using sets, are there any built-in methods that might help make this code even simpler?
Learners, PR Template
Self checklist
Changelist
I could understand code that most of them had complexity with nested loops. I refactored them by using Set and one loops to help complexity in both JS and PY.
Questions
No question