Yahoo Interview Question for Software Engineer / Developers






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

Great solution Anant !

- Time pass ! February 19, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

solution seems incomplete.. boundary cases shud be considered.. like (11:50 AM, 15) will make it 12:05 PM and vice versa for PM case..

I would add the case at the end to check
if (Suffix==AM && Hrs>12) --> Hrs=Hrs-12 and Suffix = PM

Similar case for PM.

- Anonymous September 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

solution seems incomplete.. boundary cases shud be considered.. like (11:50 AM, 15) will make it 12:05 PM and vice versa for PM case..

I would add the case at the end to check
if (Suffix==AM && Hrs>12) --> Hrs=Hrs-12 and Suffix = PM

Similar case for PM.

- Hetal September 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how about this?

let from first argument we get hh, mm and meridian = {AM = 0, PM = 1}. from second argument we get x the minutes to be added.
1. mm = (mm+x)%60;
2. hh = ((mm+x)/60+hh)%24
3. if (hh > 12) { meridian = 1-meridian; hh %= 12;}

- Anonymous December 26, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how about this?

let from first argument we get hh, mm and meridian = {AM = 0, PM = 1}. from second argument we get x the minutes to be added.
1. mm = (mm+x)%60;
2. hh = ((mm+x)/60+hh)%24
3. if (hh > 12) { meridian = 1-meridian; hh %= 12;}

- Anonymous December 26, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

anant's method with a small change..
convert "HH" to minutes by HH*60
now add MM to HH*60,
add the x minutes to be added.
If AM leave it as HH*60 + MM +x else make the HH*60+MM+x+ (12*60)

converting back to the format needed should be trivial right?

- clrs March 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

mm = (mm+x)%60;
if (suffix == PM)
hh = hh + 12;
hh = ((mm+x)/60+hh)%24
if (hh > 12) { hh %= 12; Suffix = PM}
else {Suffix = AM}

- Anonymous August 05, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

mm = (mm+x)%60;
if (suffix == PM)
hh = hh + 12;
hh = ((mm+x)/60+hh)%24
if (hh > 12) { hh %= 12; Suffix = PM}
else {Suffix = AM}

- Naveen August 05, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

mm = (mm+x)%60;
if (suffix == PM)
hh = hh + 12;
hh = ((mm+x)/60+hh)%24
if (hh > 12) { hh %= 12; Suffix = PM}
else {Suffix = AM}

- Naveen August 05, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 0 vote

1.convert first argument in minutes 10*60 + 23
2. add iind to the minutes = 623 + 13
3. Minute = 636%60
4. Hrs = (int ) 636 / 60
5. return back the result like "hh:mm"

- Anant January 15, 2009 | 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