Skip to content

Commit f037490

Browse files
authored
feat: add python solution to lc problem: No.1344 (#1320)
1 parent f0cda23 commit f037490

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

solution/1300-1399/1344.Angle Between Hands of a Clock/README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,21 @@
6060

6161
<!-- 这里可写通用的实现逻辑 -->
6262

63+
时针每小时移动 30 度,每分钟移动 0.5 度。分针每分钟移动 6 度。如果指针之间的夹角大于 180 度,则取其与 360 度的差值,以确保获得最小的夹角。
64+
6365
<!-- tabs:start -->
6466

6567
### **Python3**
6668

6769
<!-- 这里可写当前语言的特殊实现逻辑 -->
6870

6971
```python
70-
72+
class Solution:
73+
def angleClock(self, hour: int, minutes: int) -> float:
74+
h = 30 * hour + 0.5 * minutes
75+
m = 6 * minutes
76+
diff = abs(h - m)
77+
return min(diff, 360 - diff)
7178
```
7279

7380
### **Java**

solution/1300-1399/1344.Angle Between Hands of a Clock/README_EN.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@
4242

4343
<!-- tabs:start -->
4444

45+
The hour hand moves 30 degrees every hour and an additional 0.5 degrees for each minute. The minute hand moves 6 degrees every minute. If the angle between the hands is greater than 180 degrees, take its difference from 360 degrees to ensure the smallest angle is obtained.
46+
4547
### **Python3**
4648

4749
```python
48-
50+
class Solution:
51+
def angleClock(self, hour: int, minutes: int) -> float:
52+
h = 30 * hour + 0.5 * minutes
53+
m = 6 * minutes
54+
diff = abs(h - m)
55+
return min(diff, 360 - diff)
4956
```
5057

5158
### **Java**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution:
2+
def angleClock(self, hour: int, minutes: int) -> float:
3+
h = 30 * hour + 0.5 * minutes
4+
m = 6 * minutes
5+
diff = abs(h - m)
6+
return min(diff, 360 - diff)

0 commit comments

Comments
 (0)