博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Distinct
阅读量:4575 次
发布时间:2019-06-08

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

1         ///  2         /// Solution A 3         /// 100/100 4         ///  5         ///  6         /// 
7 public static int solution(int[] A) 8 { 9 if (A.Length == 0) return 0;10 int result = 1;11 Array.Sort(A);12 for (int i = 1; i < A.Length; i++)13 {14 if (A[i] != A[i - 1])15 result++;16 }17 return result;18 }19 20 /// 21 /// Solution B22 /// 100/10023 /// 24 /// 25 ///
26 public static int solution(int[] A)27 {28 HashSet
hs = new HashSet
();29 foreach (int num in A)30 {31 hs.Add(num);32 }33 return hs.Count;34 }

 

转载于:https://www.cnblogs.com/HuoAA/p/4675824.html

你可能感兴趣的文章
Android模拟器使用SD卡
查看>>
新手Oracle安装及使用入门
查看>>
4/25
查看>>
python3 第十七章 - sequence(序列)
查看>>
关于新标签dialog
查看>>
最大正方形
查看>>
万径人踪灭(FFT+manacher)
查看>>
技术规格说明书
查看>>
图写成一个类(2)
查看>>
Segmentation fault (core dumped) 错误的一种解决场景
查看>>
hdu1150 Machine Schedule (匈牙利算法模版)
查看>>
惠普 hpssacli 工具使用
查看>>
Solr综合案例深入练习
查看>>
关于strcpy的实现.
查看>>
mysql新建表示,时间字段timetamp碰到的问题
查看>>
在 RHEL/CentOS 7 上配置NTP时间服务器
查看>>
链表:创建一个简单的链表并输出链表内容
查看>>
python 集中基本数据类型
查看>>
may be a diary?
查看>>
洛谷.2590.[ZJOI2008]树的统计(树分块)
查看>>