Recca Chao 的 gitHub page

推廣網站開發,包含 Laravel 和 Kotlin 後端撰寫、自動化測試、讀書心得等。Taiwan Kotlin User Group 管理員。

View on GitHub

Hi, here’s your problem today. This problem was recently asked by AirBNB:

A majority element is an element that appears more than half the time. Given a list with a majority element, find the majority element.

Here’s an example and some starting code.

def majority_element(nums):
  # Fill this in.

print(majority_element([3, 5, 3, 3, 2, 4, 3]))
# 3