<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>angle Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/angle/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/angle/</link>
	<description></description>
	<lastBuildDate>Fri, 14 Feb 2020 06:38:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.8</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>angle Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/angle/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 1344. Angle Between Hands of a Clock</title>
		<link>https://zxi.mytechroad.com/blog/math/leetcode-1344-angle-between-hands-of-a-clock/</link>
					<comments>https://zxi.mytechroad.com/blog/math/leetcode-1344-angle-between-hands-of-a-clock/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Fri, 14 Feb 2020 06:36:37 +0000</pubDate>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[angle]]></category>
		<category><![CDATA[clock]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[medium]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=6309</guid>

					<description><![CDATA[<p>Given two numbers,&#160;hour&#160;and&#160;minutes. Return the smaller angle (in sexagesimal units) formed between the&#160;hour&#160;and the&#160;minute&#160;hand. Example 1: Input: hour = 12, minutes = 30 Output: 165&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/math/leetcode-1344-angle-between-hands-of-a-clock/">花花酱 LeetCode 1344. Angle Between Hands of a Clock</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Given two numbers,&nbsp;<code>hour</code>&nbsp;and&nbsp;<code>minutes</code>. Return the smaller angle (in sexagesimal units) formed between the&nbsp;<code>hour</code>&nbsp;and the&nbsp;<code>minute</code>&nbsp;hand.</p>



<p><strong>Example 1:</strong></p>



<figure class="wp-block-image is-resized"><img src="https://assets.leetcode.com/uploads/2019/12/26/sample_1_1673.png" alt="" width="184" height="181"/></figure>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> hour = 12, minutes = 30
<strong>Output:</strong> 165
</pre>



<p><strong>Example 2:</strong></p>



<figure class="wp-block-image is-resized"><img src="https://assets.leetcode.com/uploads/2019/12/26/sample_2_1673.png" alt="" width="181" height="181"/></figure>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> hour = 3, minutes = 30
<strong>Output:</strong> 75
</pre>



<p><strong>Example 3:</strong></p>



<figure class="wp-block-image is-resized"><img src="https://assets.leetcode.com/uploads/2019/12/26/sample_3_1673.png" alt="" width="181" height="181"/></figure>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> hour = 3, minutes = 15
<strong>Output:</strong> 7.5
</pre>



<p><strong>Example 4:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> hour = 4, minutes = 50
<strong>Output:</strong> 155
</pre>



<p><strong>Example 5:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> hour = 12, minutes = 0
<strong>Output:</strong> 0
</pre>



<p><strong>Constraints:</strong></p>



<ul><li><code>1 &lt;= hour &lt;= 12</code></li><li><code>0 &lt;= minutes &lt;= 59</code></li><li>Answers within&nbsp;<code>10^-5</code>&nbsp;of the actual value will be accepted as correct.</li></ul>



<p>Solution: Math</p>



<ol><li>Compute the angle of the hour hand (h  + m / 60.0) * 360 / 12 as a_h</li><li>Compute the angle of the minute hand m / 60.0 * 360 as a_m</li><li>ans = min(abs(a_h &#8211; a_m), 360 &#8211; abs(a_h &#8211; a_m))</li></ol>



<p>Time complexity: O(1)<br>Space complexity: O(1)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  double angleClock(int hour, int minutes) {
    double a_m = minutes * 360 / 60;
    double a_h = (hour + minutes / 60.0) * 360 / 12;
    return min(abs(a_m - a_h), 360 - abs(a_m - a_h));
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/math/leetcode-1344-angle-between-hands-of-a-clock/">花花酱 LeetCode 1344. Angle Between Hands of a Clock</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/math/leetcode-1344-angle-between-hands-of-a-clock/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
