Ad
Graphs
Data Structures
Algorithms
Logic

Given a matrix return the row that is of different length than other rows, it can be greater or lesser than the other rows. The rows can contain anything (numbers, characters, strings,floats,etc). The matrix will always have more than 2 rows and only one row will be estranged from the others.

Some examples:

estranged_row([[1,2,3,4],
[5,6,7,8],
[9,10,11]])
will return a value of 2(the last row)

estranged_row([[9,2],
[24],
['a',8]])
will return a value of 1 (the middle row)

estranged_row([[9,'a',0.1,'alpha'],
[22,'a',46,(82,24)],
[9,3,22,11],
[(1,8),22,35,72],
[18,22,['fox','rabbit','clover']]])
will return a value of 4 (the last row)

from collections import Counter

def estranged_row(m:list) -> int:
    estr= Counter([len(a) for a in m]).most_common(1)[0][0]
    for index,items in enumerate(m):
        if len(items) != estr:
            return index