Welcome to the SkillShow repository! This is a collaborative space for beginners and intermediate programmers to showcase their skills through coding tasks and portfolio submissions. 💻✨
Is your feature request related to a problem? Please describe.
Yes, the request is related to finding the majority element in an array, which is a common problem in competitive programming and algorithms. The majority element is the element that appears more than n/2 times, where n is the size of the array. This is useful in scenarios involving voting systems, data analysis, and pattern detection.
Describe the solution you'd like.
The solution should efficiently find the majority element by using an approach such as Moore's Voting Algorithm or a frequency count. If no such element exists, the function should return -1. The time complexity should ideally be linear, and the space complexity should be minimized.
Add any other context or screenshots about the feature request here.
Thanks for opening this Issue 🙌 , Welcome to SkillShow 💖 We will review everything and get back to you. Make sure to give a star to this repo before making a fork! Thank you :)
Initiative (Required)
Hacktoberfest 2024 🎃
Is your feature request related to a problem? Please describe.
Yes, the request is related to finding the majority element in an array, which is a common problem in competitive programming and algorithms. The majority element is the element that appears more than n/2 times, where n is the size of the array. This is useful in scenarios involving voting systems, data analysis, and pattern detection.
Describe the solution you'd like.
The solution should efficiently find the majority element by using an approach such as Moore's Voting Algorithm or a frequency count. If no such element exists, the function should return -1. The time complexity should ideally be linear, and the space complexity should be minimized.
Add any other context or screenshots about the feature request here.
Example test cases:
Input: nums = [2, 2, 1, 1, 1, 2, 2] → Output: 2 Input: nums = [3, 3, 4, 2, 4, 4, 2, 4, 4] → Output: 4 Input: nums = [3, 2, 2, 1, 8] → Output: -1