Skip to content

Commit 47514f0

Browse files
authored
Merge pull request #335 from sir-gon/develop
[BUGFIX] [Hacker Rank] Interview Preparation Kit: Greedy Algorithms: …
2 parents f78cf58 + d0dbc3a commit 47514f0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

algorithm-exercises-java/src/main/java/ae/hackerrank/interview_preparation_kit/greedy_algorithms/GreedyFlorist.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ private GreedyFlorist() {
2323
*/
2424
public static int getMinimumCost(int k, int[] c) {
2525
List<Integer> flowers = Arrays.stream(c).boxed().collect(Collectors.toList());
26+
Collections.sort(flowers);
2627
Collections.reverse(flowers);
2728

2829
int totalCost = 0;

algorithm-exercises-java/src/test/resources/hackerrank/interview_preparation_kit/greedy_algorithms/greedy_florist.testcases.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,18 @@
1616
"k": 3,
1717
"c": [1, 3, 5, 7, 9],
1818
"expected": 29
19+
},
20+
{
21+
"title": "Test case 1",
22+
"k": 3,
23+
"c": [
24+
390225, 426456, 688267, 800389, 990107, 439248, 240638, 15991, 874479,
25+
568754, 729927, 980985, 132244, 488186, 5037, 721765, 251885, 28458,
26+
23710, 281490, 30935, 897665, 768945, 337228, 533277, 959855, 927447,
27+
941485, 24242, 684459, 312855, 716170, 512600, 608266, 779912, 950103,
28+
211756, 665028, 642996, 262173, 789020, 932421, 390745, 433434, 350262,
29+
463568, 668809, 305781, 815771, 550800
30+
],
31+
"expected": 163578911
1932
}
2033
]

0 commit comments

Comments
 (0)