GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

pls help me with code

Questions: Understand the code snippet below and do as instructed in ‘TODO’ section.
 
Code Snippet:
 
a = [1,2,3,4,10,20,30]  # random length between 1 to 10,000, random content 1 to 10,000
b = [20,30,1,2,1,3,4,4,5]
 
def mergeCounter(a,b):
response = {}
 
 # Rules:
# modify of array a and b is not allowed
# merge of a and b is not allowed
# you can only use one loop
 
 ###
# TODO: Implement this function in below section
###
 
 
 # Output:
 #          Key: number
#          value: frequency of key from array a and b
# Example:
# a = [1,2,1,5]
# b = [1,3,3,4,5]
# response = {1:3,2:1,5:2,3:2,4:1}
       
 return response
 
# Testing
mergeCounter (a,b)

asked Jan 18, 2017 by Vasavi Ramachandran

1 Answer

The function to write will count the occurrences of particular numbers in a and b collectively. Occurrences greater than zero are to be output. Key in output is the number whose occurrence count is to be printed and Value in output is the number of occurrences.

answered Jan 18, 2017 by rishidaraj
...