From 0a52b900e81df29fc4fe75be87e056a4fbeb3bb9 Mon Sep 17 00:00:00 2001 From: Deepak Chauhan Date: Mon, 30 Dec 2019 00:56:30 -0800 Subject: [PATCH 1/2] Added code for Max Min in Java from Greedy Algo --- Greedy Algorithm/MaxMin.java | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Greedy Algorithm/MaxMin.java diff --git a/Greedy Algorithm/MaxMin.java b/Greedy Algorithm/MaxMin.java new file mode 100644 index 0000000..662572f --- /dev/null +++ b/Greedy Algorithm/MaxMin.java @@ -0,0 +1,53 @@ +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.regex.*; + +public class Solution { + + // Complete the maxMin function below. + static int maxMin(int k, int[] arr) { + Arrays.sort(arr); + int min = 1000000000; + int i = 0; + for(i=0; (i+k-1) Date: Mon, 30 Dec 2019 00:57:52 -0800 Subject: [PATCH 2/2] Updated Readme marking solved problem as done --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b23abc..af4f8f1 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ in C++, Java, Python and Javascript. | |[Luck Balance](https://www.hackerrank.com/challenges/luck-balance/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=greedy-algorithms)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Greedy%20Algorithm/luck_balance.cpp)||[Done](/Greedy%20Algorithm/LuckBalance.py)|| ||[Minimum Absolute Difference in an Array](https://www.hackerrank.com/challenges/minimum-absolute-difference-in-an-array/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=greedy-algorithms)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Greedy%20Algorithm/minimum_absolute_difference_in_an_array.cpp)||[Done](/Greedy%20Algorithm/MinimumDifference.py)|| ||[Greedy Florist](https://www.hackerrank.com/challenges/greedy-florist/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=greedy-algorithms)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Greedy%20Algorithm/greedy_florist.cpp)||[Done](/Greedy%20Algorithm/GreedyFlorist.py)|| -||[Max Min](https://www.hackerrank.com/challenges/angry-children/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=greedy-algorithms)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Greedy%20Algorithm/max_min.cpp)||[Done](/Greedy%20Algorithm/MaxMin.py)|| +||[Max Min](https://www.hackerrank.com/challenges/angry-children/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=greedy-algorithms)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Greedy%20Algorithm/max_min.cpp)|[Done](/Greedy%20Algorithm/MaxMin.java)|[Done](/Greedy%20Algorithm/MaxMin.py)|| ||[Reverse Shuffle Merge](https://www.hackerrank.com/challenges/reverse-shuffle-merge/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=greedy-algorithms)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Greedy%20Algorithm/reverse_shuffle_merge.cpp)||[Done](/Greedy%20Algorithm/ReverseShuffleMerge.py)|| |Search| || ||| ||[Minimum Time Required](https://www.hackerrank.com/challenges/minimum-time-required/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=search)|[Done](https://github.com/maze-runnar/interview-preparation-kit/blob/master/Seach/minimum_time_required.cpp)||[Done](/Search/MinimumTime.py)||