Conversation
andriibugaiov
left a comment
There was a problem hiding this comment.
I wonder if you see some sort of label, saying that I have approved the request? The should be one...otherwise we may reconsider our workflow as it adds confusion and it is a bit annoying to approve the request and then write 'you can merge it'.
Or, I guess, we could stick to this criteria: if after receiving feedback you don't see red label, that means the request is approved. What do you think?
| for (int i = 0; i < nums1.size(); ++i) { | ||
| exist[nums1[i]] = true; | ||
| } | ||
| for (int i = 0; i < nums2.size(); ++i) { |
There was a problem hiding this comment.
You don't really need an index here. Just do - for(int num : nums2) {}
There was a problem hiding this comment.
Ok. This will make code more readable.
| class Solution { | ||
| public: | ||
| vector<int> intersection(vector<int>& nums1, vector<int>& nums2) { | ||
| //if (nums1.size() > nums2.size()) return intersection(nums2, nums1); |
There was a problem hiding this comment.
This is actually a very good idea :) Not sure why you commented it out.
There was a problem hiding this comment.
Because if their actual sizes are different it does not say anuthing about sizes of their unique arrays.
So I thought that this will give us profit only sometimes.
| vector<int> intersection(vector<int>& nums1, vector<int>& nums2) { | ||
| //if (nums1.size() > nums2.size()) return intersection(nums2, nums1); | ||
|
|
||
| // The idea here is to use some hash table data structure (set or map). |
There was a problem hiding this comment.
unordered_set is preferable. You don't wan't to use stuff that adds complexity and brings no value.
There was a problem hiding this comment.
I also done this with unordered set first.
But with unordered set running time was slightly bigger I guess it is because of bigger hidden constant of operation erase in hset than operator [] in hmap.
https://leetcode.com/submissions/detail/80045924/
|
Don't forget to solve second version of the problem :) |
|
You didnt reply on this: "I wonder if you see some sort of label, saying that I have approved the request? The should be one...otherwise we may reconsider our workflow as it adds confusion and it is a bit annoying to approve the request and then write 'you can merge it'. Or, I guess, we could stick to this criteria: if after receiving feedback you don't see red label, that means the request is approved. What do you think?" and this: "Don't forget to solve second version of the problem :) |
No description provided.