Ayush7614 / Daily-Coding-DS-ALGO-Practice

A open source project🚀 for bringing all interview💥💥 and competative📘 programming💥💥 question under one repo📐📐
https://daily-ds-algo.github.io/DS-Algo-Website/
MIT License
321 stars 474 forks source link

N/3 Repeat Number #1790

Open joydeepnandi opened 3 years ago

joydeepnandi commented 3 years ago

You’re given a read only array of n integers. Find out if any integer occurs more than n/3 times in the array in linear time and constant additional space.

If so, return the integer. If not, return -1.

If there are multiple solutions, return any one.

Sample Testcase:

Input : [1 2 3 1 1] Output : 1 1 occurs 3 times which is more than 5/3 times.

Input:[2,2,3,3] Output: Any number that appears more than n/3 times. Here your output can either be 2 or 3.

joydeepnandi commented 3 years ago

I would like to solve this problem using Python. Please assign this issue to me under LGM SOC'21 @Ayush7614 @Amit366

joydeepnandi commented 3 years ago

Could you please assign this to me? @ravikr126

siddhi-244 commented 3 years ago

Can I try in c?