Skip to content

Commit 99b9d0a

Browse files
committed
1344_Angle_Between_Hands_of_a_Clock
1 parent 2a297cb commit 99b9d0a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ BFS, DFS, Dijkstra, Floyd–Warshall, Bellman-Ford, Kruskal, Prim's, Minimum Spa
822822
|11| **[239. Sliding Window Maximum](https://tinyurl.com/rvhujl5)** | [Python](https://tinyurl.com/wu6rdaw/239_Sliding_Window_Maximum.py)| **[Video 1](https://tinyurl.com/v767bl3)**, [Official](https://tinyurl.com/www4np2), [Art 1](https://tinyurl.com/y8nbroux), [Art 2](https://tinyurl.com/s62fzls), **[Art 3](https://tinyurl.com/vd3dtch)**, **[Art 4](https://tinyurl.com/yx3sjp46)** | Hard | 📌 Here, I have specifically focused on solving it with AVL and Red-Black Tree. A "Queue" approach can be found o Queue section |
823823
|12| **[398. Random Pick Index](https://tinyurl.com/ydf3t2ke)** | [Python](https://tinyurl.com/wu6rdaw/398_Random_Pick_Index.py)| **[Video 1](https://tinyurl.com/ycjk3gk6)**, [Art 1](https://tinyurl.com/ych82hfp), [Art 2](https://tinyurl.com/y8hogyty), [Art 3](https://tinyurl.com/y7slu8x2), [Art 4](https://tinyurl.com/y896sqmt), [Art 5](https://tinyurl.com/yafb3esf) | Medium (Really!!??) | 📌 **Reservoir sampling**, What's the point of asking this into an interview!!?? |
824824
|13| **[319. Bulb Switcher](https://tinyurl.com/ycygg2ju)** | [Python](https://tinyurl.com/wu6rdaw/319_Bulb_Switcher.py)| [Art 1](https://tinyurl.com/y886rzfe), [Art 2](https://tinyurl.com/y9n7vo2x), [Art 3](https://tinyurl.com/ya3fookw) | Medium (Really!!??) | Are you fucking kidding me!! We are programmers, not math wizard. |
825+
|14| **[1344. Angle Between Hands of a Clock](https://tinyurl.com/yy3g8mg6)** | [Python](https://tinyurl.com/wu6rdaw/1344_Angle_Between_Hands_of_a_Clock.py), [Swift](https://tinyurl.com/wuja3c4/1344_Angle_Between_Hands_of_a_Clock.swift)| --- | Medium | FB really likes to ask tricky question. |
825826

826827
</p>
827828
</details>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Foundation
2+
3+
class Solution {
4+
func angleClock(_ hour: Int, _ minutes: Int) -> Double {
5+
let (h, m) = (Double(hour), Double(minutes))
6+
var (hourPassed, minutesPassed) = (Double((30 * hour) % 360), Double((6 * minutes) % 360))
7+
let hourAdjustmanentForMinute = 0.5 * Double(minutes)
8+
hourPassed += hourAdjustmanentForMinute
9+
10+
var diff: Double = 0
11+
if minutesPassed == hourPassed {
12+
return diff
13+
}
14+
diff = Double(abs(minutesPassed - hourPassed))
15+
return diff < Double(180) ? diff : Double(360 - diff)
16+
}
17+
}

0 commit comments

Comments
 (0)