Problem 108925 · easy · Phase 01 Prerequisites & Setup

Spot the Differences

lists · comparison · indexing

Two students typed the same answer key. Write mismatch_positions(a, b) that returns a list of every index i where a[i] != b[i], in increasing order. Both lists have the same length. Return an empty list if they are identical.

Examples

Input:  a = [1, 2, 3, 4], b = [1, 0, 3, 9]
Output: [1, 3]

Input:  a = ["a", "b"], b = ["a", "b"]
Output: []

Constraints

  • len(a) == len(b)
  • 0 <= len(a) <= 5000

Goals

  • Compare two lists position by position
  • Collect the indexes where they disagree
Starting Python…