Amazon Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

suppose `hour' is in [0..11]
and `min' is in [0..59]
we do not take seconds into account for simplicity

compute_angle(int hour, int min) {
   float ha = (float)(hour + min / 60.0f) * 360 / 12.0f; // position of hours hand
   float ma = (float)min * 360 / 60.0f; // position of minutes hand
   float a = std::abs(ha - ma);
   if(a > 180)
       a = 360 - a;
   return a; // return the angle difference
}

- pavel.em October 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

find the angle bvetween the hands of a clock....
if "H" is the hours and "M" is the mins...then angle can be directly obtained by
ANGLE = 30H - (11/2)M
For example...when da time is 9:30...angle is
30*9 - (11/2)*30 = 270-165=105 degrees..

hope dat was useful.....

- shivturner November 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

dat == that?

Learn some English first.

- LK December 09, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The above formula ANGLE = 30H - (11/2) M is obtained as follows :

For hour hand :
12*60 = 360
=> x min = x/2

For min hand :
60 min = 360 => x min = 6x

total min = h*60+m

so diff = (h*60+m)/2 - 6m = 30h - (11/2)m

- Srikant Aggarwal November 19, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Let time be given as H:M where H is Hours and M is Minutes.
Angle covered by Hour hand in covering H hours = (H%12)*30 degrees
Additional angle covered by Hour hand in covering M minutes = (M%60)/2 degrees

Angle covered by Minute hand= (M%60)*6 degrees
So difference between them
abs( (H%12)*30 + (M%60)/2 - (M%60)*6 )
==> abs( (H%12)*30 - ((M%60)*11)/2 ) degrees

- Devansh December 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static double angleBetweenHourAndMinuteHand(double hour,double minute){
		
		double thour = (hour *30) + (30 * ((minute * 6)/360));
		double angle = Math.abs((thour) - (minute * 6));
		return angle > 180 ? 360 - angle : angle;
	}

- nmc January 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

30 * HH - 5.5 * MM

- akash bansal July 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static double

- Anonymous August 08, 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