| 1 | class Solution: |
| 2 | def majorityElement(self, nums: List[int]) -> int: |
| 3 | #we make a set of the given list |
| 4 | s=list(set(nums)) |
| 5 | #iterate over the set |
| 6 | for i in range(len(s)): |
| 7 | #we check if the count of the element is >n/2 by using the count function as soon as we get that required element which satisfies the condition we break out the loop and return the value to the main function. |
| 8 | if nums.count(s[i])>len(nums)/2: |
| 9 | break |
| 10 | return s[i] |
nothing calls this directly
no outgoing calls
no test coverage detected