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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -