Yatra.com Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

select studentName from student where 'DS' IN(subject1,subject2,subject3,subject4,subject5)
OR 'Networking' IN (subject1,subject2,subject3,subject4,subject5)

- Sumanth January 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

i agree with sumanth..good approach bro

- rockstar January 26, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Above Query is wrong.It would also return students studying more than 2 subjects.We need to return students studying either DS or Networking and not any other subjects, else the query is pretty easy.

So we can do concatenation of all the subjects and check that it is either DSNetworking or NetworkingDS. This would do the job.

- Algorithmist April 14, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Any approach that doesn't involve explicitly listing the subjects?

- eugene.yarovoi January 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Only thought I get is, stored procedure and use information_schema(in case of mysql). I am also looking for a single query

- Sumanth February 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

select * from student where "DS" IN (sub1, sub2, sub3, sub4, sub5) AND "Networking" IN (sub1, sub2, sub3, sub4, sub5);

- Darshan October 01, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

select studentName from student where (subject1='DS' OR subject1='Networking') OR (subject2='DS' OR subject2='Networking') OR (subject3='DS' OR subject3='Networking') OR (subject4='DS' OR subject4='Networking') OR (subject5='DS' OR subject5='Networking')

- durai January 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

any other better approach than this. I also replied with this solution but the interviewer was keen to know any better approach, as the number of subjects may increase it is not much efficient.

- priyankajaggi4 January 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Well, even with possible 5 different subjects the subjects should go into another table. And then join the student table with the subjects table for the query.

select distinct studentName from students, subjects where students.id = subjects.id and (subjects.title = 'DS' or subject.title = 'Networking')

- Selmeczy, Péter January 26, 2012 | 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