Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
You may assume that the array is non-empty and the majority element always exist in the array.
Example 1:
Example 2:
wx62ea2466cca9a 博主文章分类:leetcode ©著作权
文章标签 leetcode-java i++ 文章分类 运维
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
You may assume that the array is non-empty and the majority element always exist in the array.
Example 1:
Example 2:
下一篇:Vue2实时监听表单变化的方法
element plus table一些使用方法,表头合并 列合并
169. Majority Element - LeetCode
简单题,可以用字典完成。注意字典迭代使用的是键值key
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M