Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cjyuan
reviewed
Oct 8, 2026
cjyuan
left a comment
There was a problem hiding this comment.
The complexity analysis on the JS implementation looks good.
Comment on lines
+12
to
22
| Time Complexity:O(nm) | ||
| Space Complexity:O(n+m) | ||
| Optimal time complexity:O(n+m) | ||
| which is the same as JavaScript const findCommonItems = (firstArray, secondArray) | ||
| """ | ||
| common_items: List[ItemType] = [] | ||
| for i in first_sequence: | ||
| for j in second_sequence: | ||
| if i == j and i not in common_items: | ||
| common_items.append(i) | ||
| return common_items |
There was a problem hiding this comment.
The complexity of this Python implementation is not O(nm).
Comment on lines
+36
to
+41
| // For two loops, we have visit each element of array in order to get the result | ||
| // so time complexity is O (n) which means linear. | ||
| // Regarding space complexity, we only get one result | ||
| // for sum and product no matter how long the array is.so it is O(1)(constant) | ||
| // While time complexity is O(n), optimal time complexity should be O(n) because loop | ||
| // has to go each single element in array. |
There was a problem hiding this comment.
Note: While the complexity remains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Self checklist
Task code
CYF-1173
Changelist
did prep and get general idea about JavaScript and Python. Also learn from test and give explanation about refactor.