Загрузка...

Majority Vote using Java | 03 Oct 2024 | GFG-POTD | Array | Data Structure | Java | Practice

Geeks-for-Geeks | Practice Problem | Problem Solution
3rd October 2024
Problem : Majority Vote using Java
Level : Medium
Language : Java
Topics Tags : Arrays | Algorithms | Data Structure
-----------------------------------------------------------------------------

⬇️ You may also visit my another playlists :

👉 LeetCode Problems :
https://www.youtube.com/playlist?list=PLFKSskMOGy_smboxEBExyDNUjPl2-H9m7&jct=wHLJE4-s90B4iUQxgNWFUXAEB-hjxg

👉 Code360 by coding ninja's mcq solution :
https://www.youtube.com/playlist?list=PLFKSskMOGy_uc43WokYuyD8PFeG0NOMwl

👉 Geeks-for-Geeks :
https://www.youtube.com/playlist?list=PLFKSskMOGy_sdf5j2Ue7CRKTBp6AyjmP3&jct=RzkZg_k8O15bu7nguNvwYpDOWNvYhg

----------------------------------------------------------

➡️ Problem Statement :

You are given an array of integer nums[] where each number represents a vote to a candidate. Return the candidates that have votes greater than one-third of the total votes, If there's not a majority vote, return -1.

Examples:

Input: nums = [2, 1, 5, 5, 5, 5, 6, 6, 6, 6, 6]
Output: [5, 6]
Explanation: 5 and 6 occur more n/3 times.
Input: nums = [1, 2, 3, 4, 5]
Output: [-1]
Explanation: no candidate occur more than n/3 times.

Expected Time Complexity: O(n)
Expected Space Complexity: O(1)

------------------------------------------------------

Stay connected with me on social media for more updates and behind-the-scenes content !

You can find me on 🔍:

📱 Instagram Profile :
https://www.instagram.com/_ganesh_p09

🌐 LinkedIn Profile :
https://www.linkedin.com/in/ganesh-prasad09

--------------------------------------------------------------

🔔 If you enjoyed the content, please subscribe to the channel for more updates! 📺

👍 If you found this video helpful, don't forget to give it a thumbs up and share it with your friends! 📤

🙏 Thank you for watching the video! 😊

----------------------------------------------------------------

#majorityvote | #gfgproblemoftheday | #todaysolution | boyermoorevotingalgorithm

Видео Majority Vote using Java | 03 Oct 2024 | GFG-POTD | Array | Data Structure | Java | Practice канала My Learning Hub
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять