Repository navigation
Conversation
… space complexities
…ate documentation
…date documentation
This comment has been minimized.
This comment has been minimized.
cjyuan
left a comment
There was a problem hiding this comment.
Analyses and implementation are correct.
| for (const item of firstArray) { | ||
| if (secondSet.has(item)) { | ||
| commonItems.add(item); | ||
| } | ||
| } |
There was a problem hiding this comment.
Note:
Most Set implementations support the common set operations such as union, intersection, difference, subset, superset, equality, add, remove, contains, size, clear, and is empty.
You could consider taking advantage of them for optimal performance.
There was a problem hiding this comment.
Thanks for the suggestion! I used a Set to make lookups faster and avoid duplicate items. @cjyuan
There was a problem hiding this comment.
I am not sure if you got what I meant.
Could you show the code to compute the intersection of two sets, firstSet and secondSet, using their built-in methods?
There was a problem hiding this comment.
Thanks for clarifying—I misunderstood your suggestion. I’ve updated the implementation to create firstSet and secondSet and use firstSet.intersection(secondSet) @cjyuan
…plify implementation
…y, and update documentation
|
Changes look good. |
Learners, PR Template
Self checklist
Task code
CYF-1173
Changelist
Refactored the Sprint 1 functions for clarity and maintainability across both JavaScript and Python implementations. Verified the existing tests still pass and the behavior remains correct.