Fred_Castro
BAN USER
Questions (1)
Comments (4)
Reputation 270
- 4of 4 votes
AnswersGiven an unordered array of positive integers, create an algorithm that makes sure no group of integers of size bigger than M have the same integers.
- Fred_Castro in United States
Input: 2,1,1,1,3,4,4,4,5 M = 2
Output: 2,1,1,3,1,4,4,5,4| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
I asked if I could use another structure to store some data and the answer was "I don't think you need it".
- Fred_Castro January 22, 2014Comment hidden because of low score. Click to expand.
0
of 0 vote
Yeah, changed it, thank you.
But also remember to cover this case:
1,1,1,2,4,4,3,4,4,4 M = 2
Comment hidden because of low score. Click to expand.
0
of 0 vote
Sorry, just swap the numbers to make smaller groups.
- Fred_Castro January 22, 2014Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
for instance:
- Fred_Castro January 22, 20141,1,2 with M = 1 -> 1,2,1 -> 1,1 was a group of same integers with size bigger than M
2,1,1 with M = 1 -> 1,2,1
1,1,1,2,3,3,3,4 with M = 2 -> 1,1,2,1,3,3,4,3