1287. Element Appearing More Than 25% In Sorted Array Easy
1/**
2 * [1287] Element Appearing More Than 25% In Sorted Array
3 *
4 * 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.
5 *
6 * Example 1:
7 *
8 * Input: arr = [1,2,2,6,6,6,6,7,10]
9 * Output: 6
10 *
11 * Example 2:
12 *
13 * Input: arr = [1,1]
14 * Output: 1
15 *
16 *
17 * Constraints:
18 *
19 * 1 <= arr.length <= 10^4
20 * 0 <= arr[i] <= 10^5
21 *
22 */
23pub struct Solution {}
24
25// problem: https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array/
26// discuss: https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array/discuss/?currentPage=1&orderBy=most_votes&query=
27
28// submission codes start here
29
30impl Solution {
31 pub fn find_special_integer(arr: Vec<i32>) -> i32 {
32 0
33 }
34}
35
36// submission codes end
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[test]
43 fn test_1287() {
44 }
45}
46
Back
© 2025 bowen.ge All Rights Reserved.