java small problem
Budget: $30 – $250 USD
Given a set of 'N' maps of lists of integers, with each element of maps having a key which is a string and value is a list of integers.
Combine all the maps into one result map by combining similar keys from all maps, if the key appears more than once.
Store the aggregate of all integers for a given key from all maps as the value of the resultant map,
Ignore the keys that are unique to only one map in the input. See Below:
PLEASE DO IMPLEMENT IN JAVA
Input
First line contains an integer N, denoting the number of maps.
Second line is a blank.
N maps are represented in the sets of lines that follow.
First line of each map contains two numbers ‘m’ and ‘l’, ’m’ being the number of elements in the map and ‘l’ being the number of elements in the list which is the value part of each map element.
In each map, the next ‘m’ lines represent each element of the map. Each line contains a key string, followed by a space, followed by the list of ‘l’ integers. Each integer is separated from the next by a space.
There is a blank line between each map.
Output
Output the map of elements after combining all values of the same key from all maps, only for the keys that appear more than once.
Print the key string and the aggregate value of the integers for that key, separated by a space.
If there is more than one element to be printed, print the output for each element in successive lines (see sample output).
Ignore the keys which are unique to only a single map.
If there are no such keys found in more than one map, print ‘none’ (without quotes.)
Code evaluation is based on your output, please follow the sample format and do NOT print anything else.
SAMPLE INPUT:
3
2 2
a 4 5
x 1 2
2 2
a 1 3
z 6 5
2 2
x 2 3
b 4 5
SAMPLE OUTPUT:
a 13
x 8
Combine all the maps into one result map by combining similar keys from all maps, if the key appears more than once.
Store the aggregate of all integers for a given key from all maps as the value of the resultant map,
Ignore the keys that are unique to only one map in the input. See Below:
PLEASE DO IMPLEMENT IN JAVA
Input
First line contains an integer N, denoting the number of maps.
Second line is a blank.
N maps are represented in the sets of lines that follow.
First line of each map contains two numbers ‘m’ and ‘l’, ’m’ being the number of elements in the map and ‘l’ being the number of elements in the list which is the value part of each map element.
In each map, the next ‘m’ lines represent each element of the map. Each line contains a key string, followed by a space, followed by the list of ‘l’ integers. Each integer is separated from the next by a space.
There is a blank line between each map.
Output
Output the map of elements after combining all values of the same key from all maps, only for the keys that appear more than once.
Print the key string and the aggregate value of the integers for that key, separated by a space.
If there is more than one element to be printed, print the output for each element in successive lines (see sample output).
Ignore the keys which are unique to only a single map.
If there are no such keys found in more than one map, print ‘none’ (without quotes.)
Code evaluation is based on your output, please follow the sample format and do NOT print anything else.
SAMPLE INPUT:
3
2 2
a 4 5
x 1 2
2 2
a 1 3
z 6 5
2 2
x 2 3
b 4 5
SAMPLE OUTPUT:
a 13
x 8
Related categories:
PHP
Business, Accounting, Human Resources & Legal
JavaScript
J2EE
Software Architecture