Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

You're not being clear enough about the question for me to take a stab at it.

- eugene.yarovoi April 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

well tell me tell u clearly with an example.. Lets take a single straight line and consider it to be road.

---------------------------------------------------------------------------------------------------> road
1 2 1 1 1 2 1 1 1 2 1 1 1 1 1 2 1 3(terminate)
(sec) (car)

so as drawn above 1 represents each second .. 2 represents the car which passes in the road. and 3 represents terminate. (may be consider it as end point.. he did not say as end point but just said 3 means terminate and if 3 is clicked no one is allowed to pass in the road and stop counting the seconds as well and exit the program) . So lets say we have detectors and microprocessors in road which controls the signal and detects the cars which are passing in the road.. we need to now cal each sec and print the total number of seconds , count the no of cars which passed in the road and therefore print out the no of cars passed in the road. and finally max time difference between the two cars which passed in the road. (so in this case the max time difference would be b/w the last two cars (last 2s(2 cars)) . i was given a method called int Getevent(); . I was asked to write the code within single loop which is inside this getevent() method.. ( java prog lang) example which i have drawn above is just for u to understand the scenario. there can be many no of cars which can pass the road like this.. so we need print out three things . i am summarizing it again.
i) print the no of seconds
ii) print the no cars passed in the road.
iii) print the maximum time difference between two cars which passed in the road.

- me.studywell April 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

So why is this hard?

int seconds = 0, cars = 0, lastCar = Integer.MAX_VALUE, maxGap = 0;
foreach (value in sequence)
{
    if (value == 1) { seconds++; }
    if (value == 2) {
        cars++;
        if (seconds - lastCarTime > maxGap) {
            maxGap = seconds - lastCarTime; }
       lastCarTime = seconds;
    }
    if (value == 3) { break; }
}

- eugene.yarovoi April 15, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>
using namespace std;
main()
{
int i,t=0,c=0,d=0,max=0;

while (1)
{
cin>>i;

if (i==1)
{
t++;
d++;
}

else if (i==2)
{
c++;
if(max<d)
{
max=d;
}
d=0;
}

else if (i==3)
{
cout<<"total tym"<<" "<<t<<"\n";
cout<<"total car"<<" "<<c<<"\n";
cout<<"max tym diff"<<" "<<max<<"\n";
break;
}
}

cin>>i;
}

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

#include<iostream>
using namespace std;
main()
{
int i,t=0,c=0,d=0,max=0;

while (1)
{
cin>>i;

if (i==1)
{
t++;
d++;
}

else if (i==2)
{
c++;
if(max<d)
{
max=d;
}
d=0;
}

else if (i==3)
{
cout<<"total tym"<<" "<<t<<"\n";
cout<<"total car"<<" "<<c<<"\n";
cout<<"max tym diff"<<" "<<max<<"\n";
break;
}
}

cin>>i;
}

- s May 07, 2012 | 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