Unique Values This function will receive a single map parameter known as a_map. a_map will contain a single letter as a string and numbers as values. This function is supposed to search a_map to find all values that appear only once in a_map. The function will create another map named to_ret. For all values that appear once in a_map the function will add the value as a key in to_ret and set the value of the key to the key of the value in a_map (swap the key-value pairs, since a_map contains letters to numbers, to_ret will contain Numbers to Letters). Finally, the function should return to_ret. Signature: public static HashMap uniqueValues(HashMap a_map) Example: INPUT: {0=M, 2=M, 3=M, 5=M, 6=n, 7=M, 9=M} OUTPUT: {n=6} INPUT: {0=A, 1=c, 2=c, 4=c, 5=a, 8=Q, 9=c} OUTPUT: {A=0, a=5, Q=8}
Unique Values
This function will receive a single map parameter known as a_map. a_map will contain a single letter as a string and numbers as values. This function is supposed to search a_map to find all values that appear only once in a_map. The function will create another map named to_ret. For all values that appear once in a_map the function will add the value as a key in to_ret and set the value of the key to the key of the value in a_map (swap the key-value pairs, since a_map contains letters to numbers, to_ret will contain Numbers to Letters). Finally, the function should return to_ret.
Signature:
public static HashMap<String, Integer> uniqueValues(HashMap<Integer, String> a_map)
Example:
INPUT: {0=M, 2=M, 3=M, 5=M, 6=n, 7=M, 9=M}
OUTPUT: {n=6}
INPUT: {0=A, 1=c, 2=c, 4=c, 5=a, 8=Q, 9=c}
OUTPUT: {A=0, a=5, Q=8}

Hashmap
A hash map is a type of data structure that may map certain keys to specific values. Any type of value or key could be used. As an illustration, if I were developing a game, I may associate each username with a friends list that is represented by the a List of Strings.
Step by step
Solved in 3 steps with 1 images









