数组中重复的数字 -python


思路:题目比较简单,之间遍历一遍数组,不存在的话将这个值放入列表,否则输出这个值

# -*- coding:utf-8 -*-
class Solution:
    # 这里要特别注意~找到任意重复的一个值并赋值到duplication[0]
    # 函数返回True/False
    def duplicate(self, numbers, duplication):
        # write code here
        lists = []
        for i in numbers:
            if i not in lists:
                lists.append(i)
            else:
                duplication[0] = i
                return True
        return False


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM