From 9e6e9e5f067367edabd91501eb9b94014a40f9f2 Mon Sep 17 00:00:00 2001 From: Ali Date: Mon, 26 May 2025 16:56:02 +0330 Subject: TWC323 --- challenge-323/deadmarshal/java/Ch1.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 challenge-323/deadmarshal/java/Ch1.java (limited to 'challenge-323/deadmarshal/java/Ch1.java') diff --git a/challenge-323/deadmarshal/java/Ch1.java b/challenge-323/deadmarshal/java/Ch1.java new file mode 100644 index 0000000000..d83355c039 --- /dev/null +++ b/challenge-323/deadmarshal/java/Ch1.java @@ -0,0 +1,16 @@ +public class Ch1 { + public static void main(String[] args) { + System.out.println(increment_decrement(new String[]{"--x", "x++", "x++"})); + System.out.println(increment_decrement(new String[]{"x++", "++x", "x++"})); + System.out.println(increment_decrement(new String[]{"x++", "++x", "--x", "x--"})); + } + + private static int increment_decrement(String[] arr) { + int x = 0; + for (String s : arr) { + if (s.contains("++")) x++; + else x--; + } + return x; + } +} -- cgit