Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finding Majority elements in list using python #255

Open
Devkesarwani opened this issue Oct 15, 2021 · 4 comments
Open

Finding Majority elements in list using python #255

Devkesarwani opened this issue Oct 15, 2021 · 4 comments

Comments

@Devkesarwani
Copy link

Given an array nums of size n, return the majority element.
The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.
Input: nums = [2,2,1,1,1,2,2]
Output: 2

### code:-
class Solution: def majorityElement(self, nums: List[int]) -> int: dict={} n = len(nums)/2 for ele in nums: try: dict[ele] += 1 except: dict[ele] = 1 for item in dict: if dict[item] >= n: return item

@akshat8171
Copy link

akshat8171 commented Oct 20, 2021

Please assign it to me i will add the solution

@SusavanMondal
Copy link

Hello, I am interested to solve this issue. Please assign it to me

@SakshamSharma07
Copy link

SakshamSharma07 commented Oct 13, 2022

@Devkesarwani i am intrested in solving this issue . please assign this project to me

@Sakshi2002-Sinha
Copy link

Hello, Can you please assign this issue to me?
Thanks in advance :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants