LeetCode Entry
1287. Element Appearing More Than 25% In Sorted Array
Most frequent element
1287. Element Appearing More Than 25% In Sorted Array easy
blog post
substack

Join me on Telegram
https://t.me/leetcode_daily_unstoppable/435
Problem TLDR
Most frequent element
Complexity
-
Time complexity: \(O(n)\)
-
Space complexity: \(O(n)\), can be O(1)
Code
fun findSpecialInteger(arr: IntArray): Int =
arr.groupBy { it }
.maxBy { (k, v) -> v.size }!!
.key