LeetCode --- 1287. Element Appearing More Than 25% In Sorted Array 解题报告
Posted 杨鑫newlfe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1287. Element Appearing More Than 25% In Sorted Array 解题报告相关的知识,希望对你有一定的参考价值。
Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.
Example 1:
Input: arr = [1,2,2,6,6,6,6,7,10] Output: 6
Example 2:
Input: arr = [1,1] Output: 1
Constraints:
1 <= arr.length <= 104
0 <= arr[i] <= 105
所有代码均可在Github中找到:
# -*- coding:utf-8 -*-
__author__ = \'yangxin_ryan\'
import collections
"""
Solutions:
题目的意思是想统计每个数组出现的次数,
当出现的数字个数占比大于等于0.25时,
返回该数字即可,默认返回第一个元素即可。
"""
class Elemen
以上是关于LeetCode --- 1287. Element Appearing More Than 25% In Sorted Array 解题报告的主要内容,如果未能解决你的问题,请参考以下文章
leetcode-15双周赛-1287-有序数组中出现次数超过25%的元素
leetcode1287. Element Appearing More Than 25% In Sorted Array
每天一道LeetCode--169.Majority Elemen
LeetCode --- 1287. Element Appearing More Than 25% In Sorted Array 解题报告