python-3.x - 问题是来自hackerrank的匹配销售
问题描述
为什么函数 dupli 无法从列表中删除所有重复元素以获得更大的值。
#value for N =42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
42 42 42 42 42 42 42 42 42 42 42
n=int(input())
N=list(map(int,input().split()))
def dupli(a):
for i in N:
if i==a:
N.remove(i)
f=[]
for i in N:
a=N.count(i)
dupli(i)
f.append(a//2)
s=0
for i in f:
s+=i
print(s)
解决方案
推荐阅读
- sql - Reshape query results in pure PostgreSQL
- docker - Which file permissions should be set for NGINX hosted files?
- macos - 更新后无法运行gem
- java - How to return multiple generated columns after insert in MyBatis(Oracle)
- java - for-each 不适用于表达式类型所需的数组或 java.lang.iterable
- spring-boot - Binding the select option list
- swift - UIStackView在collectionview布局内容跳转
- python - About what scatter plot is proportional?
- windows - JMeter.bat runs but doesn't start application
- mongodb - 如何获取父文档的所有字段?