Given two lists, write a program to return a list that contains only the common elements between the lists (without duplication). Make sure your program works on two lists of different sizes.
Two list of int a,b
The length of a and b may not be equal
A list of non-repeat common elements in ascending order
1 2 3 4 5 3 88 6 4 5 5 5 5 3 1 9 10 456 23
1 3 4 5
13 12 15 3 12 13 7 8 18 6 4 15 15 8 0 3 17 8 1 15
3 8 15
15 6 12 16 9 13 3 15 17 17 15 8 13 9 12 9 11 2 10 5
9 12 13 15
Brute force: two loops O(N^2)
Pruning brute force: sort before loops O(N log N)
Set: O(N log N)
also numpy has function to do this
ID | User | Problem | Subject | Hit | Post Date |
沒有發現任何「解題報告」 |