Sets, so by definition they're unique.
Try to rename
commonUniqueValues (=intersection) and maybe it will be easier to see.
@danieldsouza23 Hashes associate arbitrary keys to arbitrary values, vectors associate indices (size_t) to arbitrary values. As you can see vector is a special hash, hit up an algorithms course/book to learn more about these two. In this special case even the arbitrary values are
ints, so that may be confusing as well.
Check constructor 2) on http://en.cppreference.com/w/cpp/container/vector/vector for meaning of
@leaptwo notice the signature:
return must return a list of lists, the full explicit typed call would look like:
return new LinkedList<List<Integer>>(Arrays.<List<Integer>>asList((List<Integer>)row));
asList is needed to create a list with a single list in it.
new LinkedList<>() around it is redundant, because it's already the correct type after returning from
asList; however it is needed because the calling code mutates the result which is not allowed by
@semov that sounds like an
Also if I understand correctly you want to use
head = head.next: this doesn't destroy the list, you just lose the reference to the beginning, but the caller will know where it starts.
In case I misunderstood, does this handle
a b c d e -> c type loops?
@mazong1123 you cannot solve it without extra space. The method argument and return value is still allocating a stack entry. "No extra space" usually means
O(1) space complexity. Any other space complexity than that means that the larger the input the more space you need to allocate. Your solution also destroys the list while traversing it which is not a good idea for a query function IRL.
@1337c0d3r thanks, better later than never :)
@Lihuas_LC whose code (and which one)? Reviewing the OP codes they all fill the data with that single element and return it without going into any loops.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.