Lunatic Server Solutions Interview Question for Developer Program Engineers


Country: United States
Interview Type: Written Test




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

so what is t supposed to be in your input/output? i dont really understand your example

- Anonymous May 23, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This problem will tell you your coding power...heh

- Anonymous May 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If the service time is 3 min per customer, then for the input
9 0 2 5 6 6 8 10 -1
the output should be:
3 6 6 8
Why your output is 2 6 8?

- sqw May 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Exactly, The output should be 3 6 6 8. Any comments on this?

- Krupal May 24, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

statement
is very clear and does not
generate any ambiguity. "If
counter is expected to be vacant
at time 't', the first person in the
queue will be scheduled for the
service". This means that the
queue status is to be printed
after the next person gets the
service. If two persons arrive at
same time, one of them will get
service when the current person
is done with. The second person
will get service after further 3
minutes. The sample input is
explained here.
Here, persons are identified by
their arrival time.
Time Queue comment
0 0
1 0
2 0 2 2 arrives
3 2 t=3, 0 is done 2 gets
service
4 2
5 2 5 5 arrives
6 5 2 over 5 gets service, 6
and 6 arrives
7 5 6 6 still waiting
8 5 6 6 still waiting, 8 8
arrives
9 6 6 gets service, 6 and 8
in the queue

- lucipher May 24, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

output must be 2 6 8

int total_wait=0;

because it ask for waiting people
on t = 2 , 1 person and get service up to t=5 and not waiting,

on t=5, 1 person come and get service up to t=8 and not waiting,

on t=6, 1 person came and waiting up to t=8,
total_wait = total_wait+1; // = 1

on t=8, this person get services before N=9, so this is not waiting,
total_wait = total_wait-1; // = 0

on t=6, 1 more person came and waiting up to t=(8+3) = 11 and this is more than N=9 so it is waiting,
total_wait = total_wait+1; // = 1

on t=8, i person came and waiting up to t=(11+3)=15
and this is more than N=9 so it is waiting,
total_wait = total_wait+1; // = 2

so total_wait person = 2 and their arrival 6 8

if you got it e-mail me harindra.it@gmail.com

- Harindra September 05, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Int checkpointTime = 9; //Read it from Console
Queue q = new Queue(); // Populate queue from Console
Int serviceTimePerCustomer = 3;
Int currentTime = 0;

While(!q.IsEmpty())
{
	If(checkpointTime == 0)
	{
		// checkpoint time reached. Queue is not empty
		// Dequeue the head and be done
		q.Dequeue();
		break;
}
If(checkpointTime < 0)
	Break;	

	Int arrivalTime = q.Dequeue();
	If(currentTime >= arrivalTime)
{
	currentTime += serviceTimePerCustomer;
}
Else
{
	currentTime = arrivalTime + serviceTimePerCustomer;
}
checkpointTime -= currentTime;
}

Print q.Count; foreach(int num in q) print num;

- nullpointer May 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

output must be 2 6 8 because it ask for waiting people

int total_wait=0;

on t = 2 , 1 person and get service up to t=5 and not waiting,

on t=5, 1 person come and get service up to t=8 and not waiting,

on t=6, 1 person came and waiting up to t=8,
total_wait = total_wait+1; // = 1

on t=8, this person get services before N=9, so this is not waiting,
total_wait = total_wait-1; // = 0

on t=6, 1 more person came and waiting up to t=(8+3) = 11 and this is more than N=9 so it is waiting,
total_wait = total_wait+1; // = 1

on t=8, i person came and waiting up to t=(11+3)=15
and this is more than N=9 so it is waiting,
total_wait = total_wait+1; // = 2

so total_wait person = 2 and their arrival 6 8

if you got it e-mail me harindra.it@gmail.com

- Harindra September 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
int main(){
int time = -1,ar=0,te=0;
int n,i=0,f, queue[100];

while(1){
scanf("%d",&n);
if(n == -1)
break;
if(time == -1){
time = n;
}
else{
if(n <= time){
if(te <= time){
if(te < n)
te = n;
}
else{
queue[i++] = n;
}
te = te+3;
}
}
}

printf("%d",i);

for(f=0;f<i;f++){
printf(" %d",queue[f]);
}

return 0;
}

- Harindra September 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Plz send full code

- Anonymous March 20, 2020 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Send full codeAs sson as possible

- Anonymous March 20, 2020 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can u plz send this code immediately?

- Sayali March 20, 2020 | Flag


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