Skip to content

Commit 0f9af5c

Browse files
committed
Add solution #1344
1 parent 49d3ace commit 0f9af5c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,243 LeetCode solutions in JavaScript
1+
# 1,244 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1020,6 +1020,7 @@
10201020
1340|[Jump Game V](./solutions/1340-jump-game-v.js)|Hard|
10211021
1342|[Number of Steps to Reduce a Number to Zero](./solutions/1342-number-of-steps-to-reduce-a-number-to-zero.js)|Easy|
10221022
1343|[Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold](./solutions/1343-number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold.js)|Medium|
1023+
1344|[Angle Between Hands of a Clock](./solutions/1344-angle-between-hands-of-a-clock.js)|Medium|
10231024
1351|[Count Negative Numbers in a Sorted Matrix](./solutions/1351-count-negative-numbers-in-a-sorted-matrix.js)|Easy|
10241025
1352|[Product of the Last K Numbers](./solutions/1352-product-of-the-last-k-numbers.js)|Medium|
10251026
1356|[Sort Integers by The Number of 1 Bits](./solutions/1356-sort-integers-by-the-number-of-1-bits.js)|Easy|
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 1344. Angle Between Hands of a Clock
3+
* https://leetcode.com/problems/angle-between-hands-of-a-clock/
4+
* Difficulty: Medium
5+
*
6+
* Given two numbers, hour and minutes, return the smaller angle (in degrees) formed between the
7+
* hour and the minute hand.
8+
*
9+
* Answers within 10-5 of the actual value will be accepted as correct.
10+
*/
11+
12+
/**
13+
* @param {number} hour
14+
* @param {number} minutes
15+
* @return {number}
16+
*/
17+
var angleClock = function(hour, minutes) {
18+
const hourAngle = (hour % 12 + minutes / 60) * 30;
19+
const minuteAngle = minutes * 6;
20+
const angle = Math.abs(hourAngle - minuteAngle);
21+
return Math.min(angle, 360 - angle);
22+
};

0 commit comments

Comments
 (0)