Skip to content

Commit 6e07981

Browse files
committed
1276_Number_of_Burgers_with_No_Waste_of_Ingredients
1 parent bba262c commit 6e07981

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ BFS, DFS, Dijkstra, Floyd–Warshall, Bellman-Ford, Kruskal, Prim's, Minimum Spa
835835
|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!!?? |
836836
|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. |
837837
|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. |
838+
|15| **[1276. Number of Burgers with No Waste of Ingredients](https://tinyurl.com/y4dl7mne)** | [Python](https://tinyurl.com/wu6rdaw/1276_Number_of_Burgers_with_No_Waste_of_Ingredients.py), [Swift](https://tinyurl.com/wuja3c4/1276_Number_of_Burgers_with_No_Waste_of_Ingredients.swift)| [Art 1](https://tinyurl.com/y2u668aa), [Art 2](https://tinyurl.com/y2u9nvre), [Art 3](https://tinyurl.com/yxdzbp9s) | Medium | Pure math |
838839

839840
</p>
840841
</details>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// TLE
2+
class Solution {
3+
func numOfBurgers(_ tomatoSlices: Int, _ cheeseSlices: Int) -> [Int] {
4+
let maxJumbo = min(tomatoSlices/4, cheeseSlices)
5+
for jumboCount in 0...maxJumbo {
6+
let remainingTomatos = tomatoSlices - jumboCount*4
7+
let remainingCheese = cheeseSlices - jumboCount*1
8+
if remainingTomatos % 2 == 0 && remainingTomatos / 2 == remainingCheese {
9+
return [jumboCount, remainingTomatos / 2]
10+
}
11+
}
12+
return []
13+
}
14+
}
15+
16+
class Solution {
17+
func numOfBurgers(_ tomatoSlices: Int, _ cheeseSlices: Int) -> [Int] {
18+
if tomatoSlices == 0 && cheeseSlices == 0 {
19+
return [0,0]
20+
}
21+
22+
let small = ((4 * cheeseSlices) - tomatoSlices)/2
23+
let jumbo = cheeseSlices - small
24+
if small > 0 && jumbo > 0 {
25+
return [jumbo, small]
26+
} else {
27+
return []
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)