leetcode 只出现一次的数字

 2023-09-06 阅读 28 评论 0

摘要:16 / 16 个通过测试用例状态:通过执行用时:12 ms内存消耗:40.8 MB提交时间:6 月,3 周之前class Solution {public int singleNumber(int[] nums) {Set<Integer> set = new HashSet();int len = 1;for (int i = 0; i &l

16 / 16 个通过测试用例
状态:通过
执行用时:12 ms
内存消耗:40.8 MB
提交时间:6 月,3 周之前

class Solution {public int singleNumber(int[] nums) {Set<Integer> set = new HashSet();int len = 1;for (int i = 0; i < nums.length; i++) {set.add(nums[i]);if (set.size() < len++){set.remove(nums[i]);len -= 2;}}return set.iterator().next();}
}

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/5275.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息