Skip to content

169. Majority Element#19

Open
ryosuketc wants to merge 1 commit intomainfrom
169_majority_element
Open

169. Majority Element#19
ryosuketc wants to merge 1 commit intomainfrom
169_majority_element

Conversation

@ryosuketc
Copy link
Owner

++num_to_count[num];
}
for (auto& [num, count] : num_to_count) {
if (count > nums.size() / 2) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一番得票数の多い物を探すという書き方もあると思いましたが、過半数を超えているものが見つかったら即返すほうがシンプルだと思いました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants