Two integer lists a and b have the same shape if there is a one-to-one substitution of values that turns a into b: whenever a[i] == a[j] then b[i] == b[j], and whenever a[i] != a[j] then b[i] != b[j]. Return True if they have the same shape.
Examples
Input: a = [1, 2, 1], b = [7, 9, 7]
Output: True
Input: a = [1, 2, 1], b = [7, 7, 7]
Output: False
Explanation: 1 -> 7 and 2 -> 7 collide, so the substitution is not one-to-one.
Input: a = [1, 2], b = [5]
Output: False
Constraints
0 <= len(a), len(b) <= 10**5- Target complexity: O(n) time.
Goals
- Build a mapping while checking consistency
- Verify the mapping is one-to-one in both directions