Twitter Interview Question for Software Engineer Interns


Country: United States




Comment hidden because of low score. Click to expand.
0
of 0 vote

I think that the answer is n/2 + 1.

- EPavlova March 23, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The Solution is - total number of prime numbers less than n + 1

- ms March 24, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

The question asks for minimum size of K, at which it becomes "impossible" to choose a team.

Consider n to be 10. Prime numbers are 2, 3, 5, 7. Which is 4. But we can choose a team with 5 players, which is stable. 5, 6, 7, 8, 9.

The answer is n/2 + 1.

- xeq March 25, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

exactly

- EPavlova March 25, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Thanks @xeq for correcting me. I agree with your answer.

- ms March 25, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

xeq@
Looks like it breaks for n=25.
Your answer K = n/2+1 is 13 but it is possible to form a team of size 13 which does not fight -
8, 9, 10, 11,12, 13, 14, 15, 17, 19, 21, 23, 25

- raghu.rvce October 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if(n%2==1) return (n-1)/2+1;
return (n/2)+1;

Reason-

We can have the numbers in following way-
1,3,5,7,9,11,... i.e all odd numbers- because if you divide odd by odd you still get back odd number. So, we just eliminated all even numbers and we can get even dividend only if we have even numbers

- mv November 21, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if(n%2==1) return (n+1)/2+1;
return (n/2)+1;

Just replaced - sign by + when n id odd

- USLabs December 30, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if(n%2==1) return (n+1)/2+1;
return (n/2)+1;

Just replaced - sign by + when n id odd

- USLabs December 30, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

why are considering odd case ? its given in question that n is guaranteed to be an even number

- inTheQuestion January 15, 2017 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More