-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Description
LeetCode Username
Sudeep_More
Problem Number, Title, and Link
https://leetcode.com/problems/majority-element/description/
Bug Category
Missing test case (Incorrect/Inefficient Code getting accepted because of missing test cases)
Bug Description
When we have input = [3,2,2,3] then what should be the output? 2 or 3?
Language Used for Code
Swift
Code used for Submit/Run operation
func majorityElement(_ nums: [Int]) -> Int {
var freq: [Int: Int] = [:]
var maj = nums.count / 2
for num in nums {
freq[num, default: 0] += 1
if freq[num]! > maj {
return num
}
}
return -1
}Expected behavior
It is returning -1, which is correct but this test case is missing.
Screenshots
No response
Additional context
No response