Skip to content

Commit 918a63b

Browse files
add 2293
1 parent f11ceac commit 918a63b

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ _If you like this project, please leave me a star._ ★
1111
| 2309 |[Greatest English Letter in Upper and Lower Case](https://leetcode.com/problems/greatest-english-letter-in-upper-and-lower-case/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2309.java) || Easy ||
1212
| 2303 |[Calculate Amount Paid in Taxes](https://leetcode.com/problems/calculate-amount-paid-in-taxes/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2303.java) || Easy ||
1313
| 2299 |[Strong Password Checker II](https://leetcode.com/problems/strong-password-checker-ii/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2299.java) || Easy ||
14+
| 2293 |[Min Max Game](https://leetcode.com/problems/min-max-game/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2293.java) || Easy ||
1415
| 2288 |[Apply Discount to Prices](https://leetcode.com/problems/apply-discount-to-prices/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2288.java) || Medium ||
1516
| 2287 |[Rearrange Characters to Make Target String](https://leetcode.com/problems/rearrange-characters-to-make-target-string/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2288.java) || Easy ||
1617
| 2284 |[Sender With Largest Word Count](https://leetcode.com/problems/sender-with-largest-word-count/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2284.java) || Medium ||
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _2293 {
4+
public static class Solution1 {
5+
public int minMaxGame(int[] nums) {
6+
if (nums.length == 1) {
7+
return nums[0];
8+
}
9+
int[] newNums = new int[nums.length / 2];
10+
boolean min = true;
11+
for (int i = 0, j = 0; i < nums.length; i += 2, j++) {
12+
if (min) {
13+
min = false;
14+
newNums[j] = Math.min(nums[i], nums[i + 1]);
15+
} else {
16+
min = true;
17+
newNums[j] = Math.max(nums[i], nums[i + 1]);
18+
}
19+
}
20+
return minMaxGame(newNums);
21+
}
22+
}
23+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.fishercoder;
2+
3+
import com.fishercoder.solutions._2293;
4+
import com.fishercoder.solutions._3;
5+
import org.junit.BeforeClass;
6+
import org.junit.Test;
7+
8+
import static org.junit.Assert.assertEquals;
9+
10+
public class _2293Test {
11+
private static _2293.Solution1 solution1;
12+
private static int expected;
13+
private static int[] nums;
14+
private static String s;
15+
16+
@BeforeClass
17+
public static void setup() {
18+
solution1 = new _2293.Solution1();
19+
}
20+
21+
@Test
22+
public void test1() {
23+
expected = 22;
24+
nums = new int[]{70, 38, 21, 22};
25+
assertEquals(expected, solution1.minMaxGame(nums));
26+
}
27+
28+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy