Consistent tag migration

Write codeEasy12 min

Your task

A library migration renamed every tag. You are given two equal-length lists: old_tags[i] is a tag before the migration and new_tags[i] is what that same item shows now. The migration is trustworthy only if it renamed consistently, every occurrence of a given old tag became one single new tag. Two different old tags are allowed to merge into the same new tag. Return true when the recorded pairs are consistent, false otherwise. For example, old ["a", "a"] with new ["b", "c"] is inconsistent, but old ["a", "b"] with new ["c", "c"] is fine.

Examples

consistent_rename(old_tags: list[str], new_tags: list[str]) -> bool
Example 1
Inputconsistent_rename(["indie", "lofi", "indie"], ["chill", "calm", "chill"])
OutputTrue
Example 2
Inputconsistent_rename(["a", "a"], ["b", "c"])
OutputFalse