Skip to content

Commit 5e4e5bb

Browse files
authored
Improved task 857
1 parent e13f8d2 commit 5e4e5bb

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ implementation 'com.github.javadev:leetcode-in-kotlin:1.11'
17191719
| 1143 |[Longest Common Subsequence](src/main/kotlin/g1101_1200/s1143_longest_common_subsequence/Solution.kt)| Medium | Top_100_Liked_Questions, String, Dynamic_Programming, Algorithm_II_Day_17_Dynamic_Programming, Dynamic_Programming_I_Day_19, Udemy_Dynamic_Programming | 307 | 38.36
17201720
| 0994 |[Rotting Oranges](src/main/kotlin/g0901_1000/s0994_rotting_oranges/Solution.kt)| Medium | Array, Breadth_First_Search, Matrix, Algorithm_I_Day_9_Breadth_First_Search_Depth_First_Search, Level_2_Day_10_Graph/BFS/DFS | 308 | 57.93
17211721
| 0864 |[Shortest Path to Get All Keys](src/main/kotlin/g0801_0900/s0864_shortest_path_to_get_all_keys/Solution.kt)| Hard | Breadth_First_Search, Bit_Manipulation | 176 | 100.00
1722-
| 0857 |[Score of Parentheses](src/main/kotlin/g0801_0900/s0857_minimum_cost_to_hire_k_workers/Solution.kt)| Hard | Array, Sorting, Greedy, Heap_Priority_Queue | 302 | 100.00
1722+
| 0857 |[Minimum Cost to Hire K Workers](src/main/kotlin/g0801_0900/s0857_minimum_cost_to_hire_k_workers/Solution.kt)| Hard | Array, Sorting, Greedy, Heap_Priority_Queue | 302 | 100.00
17231723
| 0856 |[Score of Parentheses](src/main/kotlin/g0801_0900/s0856_score_of_parentheses/Solution.kt)| Medium | String, Stack | 129 | 84.62
17241724
| 0855 |[Exam Room](src/main/kotlin/g0801_0900/s0855_exam_room/ExamRoom.kt)| Medium | Design, Ordered_Set | 644 | 83.33
17251725
| 0854 |[K-Similar Strings](src/main/kotlin/g0801_0900/s0854_k_similar_strings/Solution.kt)| Hard | String, Breadth_First_Search | 136 | 100.00
Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
1-
856\. Score of Parentheses
1+
857\. Minimum Cost to Hire K Workers
22

3-
Medium
3+
Hard
44

5-
Given a balanced parentheses string `s`, return _the **score** of the string_.
5+
There are `n` workers. You are given two integer arrays `quality` and `wage` where `quality[i]` is the quality of the <code>i<sup>th</sup></code> worker and `wage[i]` is the minimum wage expectation for the <code>i<sup>th</sup></code> worker.
66

7-
The **score** of a balanced parentheses string is based on the following rule:
7+
We want to hire exactly `k` workers to form a paid group. To hire a group of `k` workers, we must pay them according to the following rules:
88

9-
* `"()"` has score `1`.
10-
* `AB` has score `A + B`, where `A` and `B` are balanced parentheses strings.
11-
* `(A)` has score `2 * A`, where `A` is a balanced parentheses string.
9+
1. Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group.
10+
2. Every worker in the paid group must be paid at least their minimum wage expectation.
1211

13-
**Example 1:**
12+
Given the integer `k`, return _the least amount of money needed to form a paid group satisfying the above conditions_. Answers within <code>10<sup>-5</sup></code> of the actual answer will be accepted.
1413

15-
**Input:** s = "()"
14+
**Example 1:**
1615

17-
**Output:** 1
16+
**Input:** quality = [10,20,5], wage = [70,50,30], k = 2
1817

19-
**Example 2:**
18+
**Output:** 105.00000
2019

21-
**Input:** s = "(())"
20+
**Explanation:** We pay 70 to 0<sup>th</sup> worker and 35 to 2<sup>nd</sup> worker.
2221

23-
**Output:** 2
22+
**Example 2:**
2423

25-
**Example 3:**
24+
**Input:** quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3
2625

27-
**Input:** s = "()()"
26+
**Output:** 30.66667
2827

29-
**Output:** 2
28+
**Explanation:** We pay 4 to 0<sup>th</sup> worker, 13.33333 to 2<sup>nd</sup> and 3<sup>rd</sup> workers separately.
3029

3130
**Constraints:**
3231

33-
* `2 <= s.length <= 50`
34-
* `s` consists of only `'('` and `')'`.
35-
* `s` is a balanced parentheses string.
32+
* `n == quality.length == wage.length`
33+
* <code>1 <= k <= n <= 10<sup>4</sup></code>
34+
* <code>1 <= quality[i], wage[i] <= 10<sup>4</sup></code>

0 commit comments

Comments
 (0)