python 3.x - Degree Of array -
we have given array a=[1,2,3,4,1,2,1,1,1,2,2] have find duplicate element array , separate array [1,1,1,1,1] , [2,2,2,2] , print largest length of array here largest length 5 [1,1,1,1,1].here try use itertools not work out.
input a=[1,2,3,1,1,1,1,2,2,2]
o/p should 5.
import itertools my_list = [1,2,2,2,1,1,2,2,2,3,4] num1=[] a, b in itertools.combinations(my_list,2): if == b: num1.append(b) print(num1) max_ele=max(num1) print(max_ele) print(num1.count(max_ele))
from collections import counter n = [1,2,2,2,1,1,2,2,2,3,4] c = counter(n) count = max(c.values()) print(count)
Comments
Post a Comment