Advertisement
Guest User

Untitled

a guest
Aug 31st, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. >>> example([1, 2, 3], [3, 3, 4, 5])
  2. 1
  3.  
  4. >>> example([1, 1, 2, 3, 4], [1, 2, 3, 4])
  5. 4
  6.  
  7. //this is python, comments if you aren't familiar
  8. def example(list1, list2):
  9. count = 0
  10. //for every item in list1
  11. for item in list1:
  12. //if list2 contains that item
  13. if item in list2:
  14. count += 1
  15. //remove the first occurrence of item from list2
  16. list2.remove(item)
  17. return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement