Consistent Code Book
A code book gives every numeric code exactly one name and every name exactly one code. codes and names have the same length: the i-th message used the code codes[i] for the name names[i].
Return True when the messages are consistent with a single code book: every code always came with the same name, and every name always came with the same code. Otherwise return False. Empty lists are consistent.
Example 1
codes [1,2,1]
names ["red","blue","red"]
returns true
Code 1 is always red and code 2 is always blue; each name has one code.
Example 2
codes [1,2,1]
names ["red","blue","green"]
returns false
Code 1 came with red once and green once.
Constraints
0 <= len(codes) <= 100andlen(names) == len(codes)-1000 <= codes[i] <= 1000- names are 1 to 10 lowercase letters
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.