aboutsummaryrefslogtreecommitdiff
path: root/challenge-320/deadmarshal/java/Ch1.java
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-320/deadmarshal/java/Ch1.java')
-rw-r--r--challenge-320/deadmarshal/java/Ch1.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-320/deadmarshal/java/Ch1.java b/challenge-320/deadmarshal/java/Ch1.java
new file mode 100644
index 0000000000..6799e5c444
--- /dev/null
+++ b/challenge-320/deadmarshal/java/Ch1.java
@@ -0,0 +1,18 @@
+public class Ch1 {
+ public static void main(String[] args) {
+ System.out.println(maximum_count(new int[]{-3, -2, -1, 1, 2, 3}));
+ System.out.println(maximum_count(new int[]{-2, -1, 0, 0, 1}));
+ System.out.println(maximum_count(new int[]{1, 2, 3, 4}));
+ }
+
+ private static int maximum_count(int[] arr) {
+ int n = 0, p = 0;
+ for (int num : arr) {
+ if (num != 0) {
+ if (num < 0) n++;
+ else p++;
+ }
+ }
+ return Math.max(n, p);
+ }
+} \ No newline at end of file