Kushal997-das / SkillShow

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. 💻✨
https://kushal997-das.github.io/SkillShow/
MIT License
24 stars 27 forks source link

Title: Implement Finding Majority Element in an Array #62

Open Ansh-Vikalp opened 17 hours ago

Ansh-Vikalp commented 17 hours ago

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

github-actions[bot] commented 17 hours ago

@Ansh-Vikalp

It's great having you contribute to this project

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 :)

github-actions[bot] commented 3 hours ago

Hi @Ansh-Vikalp 👋, your issue #62 has been successfully closed ✅. Thank you for your valuable contribution! 🙌