11.12.2023
1287. Element Appearing More Than 25% In Sorted Array easy
blog post
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