LeetCode题解(1133):最大唯一数(Python)
发布日期:2021-06-29 20:09:45 浏览次数:2 分类:技术文章

本文共 504 字,大约阅读时间需要 1 分钟。

题目:(简单)

标签:哈希表、数组

解法 时间复杂度 空间复杂度 执行用时
Ans 1 (Python) O ( N ) O(N) O(N) O ( N ) O(N) O(N) 56ms (86.25%)
Ans 2 (Python)
Ans 3 (Python)

解法一:

class Solution:    def largestUniqueNumber(self, A: List[int]) -> int:        remove = set()        number = set()        for n in A:            if n not in remove:                if n not in number:                    number.add(n)                else:                    number.remove(n)                    remove.add(n)        return max(number) if number else -1

转载地址:https://dataartist.blog.csdn.net/article/details/109845274 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:LeetCode题解(1152):用户网站访问行为分析(Python)
下一篇:LeetCode题解(1090):受标签影响的最大值(Python)

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月09日 22时31分06秒