【leetcode】169. 多数元素( Majority Element )

题目描述 【leetcode】169. 多数元素( Majority Element ) 给定一个大小为 n 的数组,找到其中的多数元素。多数元素是指在数组中出现次数大于 ⌊ n/2 ⌋ 的元素。web 你能够假设数组是非空的,而且给定的数组老是存在多数元素。 算法 第一次解答 思路: 首先排序,而后从左到右便利数组, 找出出现超过 n/2 次的数组 test case: [3,2,3] [2,2
相关文章
相关标签/搜索