当前位置:网站首页>Find the ArrayList < double > with the most occurrences in ArrayList < ArrayList < double >
Find the ArrayList < double > with the most occurrences in ArrayList < ArrayList < double >
2022-07-24 06:10:00 【A little cute C】
public static ArrayList<Double> candidate (ArrayList<ArrayList<Double>> list) // Find the number that appears the most in the array
{
// map Of key Store the numbers in the array ,value Store the number of occurrences of this number
HashMap<ArrayList<Double>, Integer> map = new HashMap<ArrayList<Double>, Integer>();
for(int i = 0; i < list.size(); i++)
{
if(map.containsKey(list.get(i)))
{
int formerValue = map.get(list.get(i));
map.put(list.get(i), formerValue + 1); // The number of times this number appears plus 1
}
else
{
map.put(list.get(i), 1); // This number appears for the first time
}
}
Collection<Integer> count = map.values();
// find map Of value The maximum , That is, the number of times that the most numbers appear in the array
int maxCount = Collections.max(count);
ArrayList<Double> maxNumber = new ArrayList<>();
for(Map.Entry<ArrayList<Double>, Integer> entry : map.entrySet())
{
// obtain value by maxCount Of key, That is, the number that appears the most times in the array
if(entry.getValue() == maxCount)
{
maxNumber = entry.getKey();
}
}
return maxNumber;
}边栏推荐
- Common features of ES6
- day6-jvm
- 单播、组播、广播、工具开发、QT Udp通讯协议开发简介及开发工具源码
- Typora installation package in November 2021, the last free version of the installation package to download v13.6.1
- Qt 使用纯代码画图异常
- Numpy cheatsheet
- Machine learning (Zhou Zhihua) Chapter 3 Notes on learning linear models
- HAL_Delay()延时误差约1ms的问题
- IoTP2PGate 两台物联网设备点对点通信快速实现方案
- 论文阅读-Endmember-Guided Unmixing Network (EGU-Net) 端元指导型高光谱解混网络
猜你喜欢

AD1256

JUC并发编程基础(8)--读写锁
![[MYCAT] MYCAT configuration file](/img/53/63a633d3ae917e3754f9f7f5c6567f.png)
[MYCAT] MYCAT configuration file

Unity(三)三维数学和坐标系统

MySQL foundation - constraints

JDBC advanced -- learning from Shang Silicon Valley (DAO)

顺序栈 C语言 进栈 出栈 遍历

The problem that the user name and password are automatically filled in when Google / Firefox manages the background new account

【树莓派4B】七、远程登录树莓派的方法总结XShell,PuTTY,vncServer,Xrdp

【USB Host】STM32H7 CubeMX移植带FreeRTOS的USB Host读取U盘,USBH_Process_OS卡死问题,有个值为0xA5A5A5A5
随机推荐
es6常用特性
Signals and systems: Hilbert transform
AD1256
day5-jvm
JUC并发编程基础(7)--多线程锁
Machine learning (Zhou Zhihua) Chapter 4 notes on learning experience of decision tree
JDBC elementary learning ------ (learning from Shang Silicon Valley)
Accessing a two-dimensional array with a pointer
JUC并发编程基础(8)--读写锁
JUC并发编程基础(6)--Lock锁
JUC并发编程基础(9)--线程池
Foundation of JUC concurrent programming (1) -- related basic concepts
JDBC进阶—— 师承尚硅谷(DAO)
Hit the wall record (continuously updated)
day5-jvm
JUC并发编程基础(4)--线程组和线程优先级
[deep learning] handwritten neural network model preservation
Foundation of JUC concurrent programming (7) -- multithread lock
使用Keras实现CNN+BiLSTM+Attention的多维(多变量)时间序列预测
精确计算时间延迟VxWorks 时间戳 详解