1、在知乎上提问,不能只贴一张图片,不然得到回答的机会减少。
有的问题可以多看几眼可以看出来,有的问题要在电脑上debug 一下,会很快找到错误。
没有几个人愿意对着你的照片敲代码,再帮您debug 代码。
2、贴代码需要贴带缩进的Python 代码。
在图片
中点击Aa 出现
这样的格式化编辑器,再点击
可以贴带缩进的Python 代码。
3、提问要贴代码文本和100%完整报错信息,描述清楚自己的问题。
下面的代码,就是带缩进的Python代码的例子。
# Sample code to perform I/O:
name = input() # Reading input from STDIN
print('Hi, %s.' % name) # Writing output to STDOUT
# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
'''
# Write your code here
n = int(input())
s = input()
A = [int(item) for item in s.split()]
def get_unique_maximum_number(A):
d = {}
for i in A:
if i not in d:
d[i] = 1
else:
d[i] += 1
maxValue = -1
for key in d:
if key > maxValue and d[key] == 1:
maxValue = key
# nums = [key for key, value in d.items() if value == 1]
# nums = [key for key in d if d[key] == 1]
# if len(nums) == 0:
# return -1
# maxValue = nums[0]
# for item in nums[1:]:
# if item > maxValue:
# maxValue = item
if maxValue >= 0:
return maxValue
else:
return -1
print(get_unique_maximum_number(A))