From 42f4d65ec8c8deb195584d26771e4f095049f7ef Mon Sep 17 00:00:00 2001
From: Jidcoo <1337753396@qq.com>
Date: Fri, 28 Feb 2025 08:42:14 +0800
Subject: [PATCH 01/32] Add test framework.
---
pom.xml | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/pom.xml b/pom.xml
index 718bd76..e2a3128 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,6 +26,13 @@
gson2.10.1
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
From 32b555b39ab87e5465df99dc06a1cb70f3a5cd02 Mon Sep 17 00:00:00 2001
From: Jidcoo <1337753396@qq.com>
Date: Sun, 2 Mar 2025 22:51:29 +0800
Subject: [PATCH 02/32] add junit test framework.
---
.gitignore | 3 +-
.../opto/lcdb/enhancer/UnitTestDriver.java | 193 ++++++++++++++++++
.../testset1/TestSet1_TestCase01.java | 27 +++
.../testset1/TestSet1_TestCase02.java | 31 +++
.../testset1/TestSet1_TestCase03.java | 31 +++
.../testset1/TestSet1_TestCase04.java | 37 ++++
.../testset1/TestSet1_TestCase05.java | 23 +++
.../testset1/TestSet1_TestCase06.java | 51 +++++
.../testset1/TestSet1_TestCase07.java | 68 ++++++
.../testset1/TestSet1_TestCase08.java | 34 +++
.../testset1/TestSet1_TestCase09.java | 67 ++++++
.../testset1/TestSet1_TestCase10.java | 33 +++
.../testset2/TestSet2_TestCase01.java | 38 ++++
.../testset2/TestSet2_TestCase02.java | 94 +++++++++
.../testset2/TestSet2_TestCase03.java | 25 +++
.../testset2/TestSet2_TestCase04.java | 42 ++++
.../testset2/TestSet2_TestCase05.java | 47 +++++
.../testset2/TestSet2_TestCase06.java | 32 +++
.../testset2/TestSet2_TestCase07.java | 39 ++++
.../testset2/TestSet2_TestCase08.java | 49 +++++
.../testset2/TestSet2_TestCase09.java | 53 +++++
.../testset2/TestSet2_TestCase10.java | 42 ++++
.../testset3/TestSet3_TestCase01.java | 34 +++
.../testset3/TestSet3_TestCase02.java | 55 +++++
.../testset3/TestSet3_TestCase03.java | 40 ++++
.../testset3/TestSet3_TestCase04.java | 36 ++++
.../testset3/TestSet3_TestCase05.java | 45 ++++
.../testset3/TestSet3_TestCase06.java | 45 ++++
.../testset3/TestSet3_TestCase07.java | 54 +++++
.../testset3/TestSet3_TestCase08.java | 34 +++
.../testset3/TestSet3_TestCase09.java | 34 +++
.../testset3/TestSet3_TestCase10.java | 40 ++++
.../testset4/TestSet4_TestCase01.java | 103 ++++++++++
.../testset4/TestSet4_TestCase02.java | 46 +++++
.../testset4/TestSet4_TestCase03.java | 86 ++++++++
.../testset4/TestSet4_TestCase04.java | 30 +++
.../testset4/TestSet4_TestCase05.java | 39 ++++
.../testset4/TestSet4_TestCase06.java | 72 +++++++
.../testset4/TestSet4_TestCase07.java | 89 ++++++++
.../testset4/TestSet4_TestCase08.java | 48 +++++
.../testset4/TestSet4_TestCase09.java | 39 ++++
.../testset4/TestSet4_TestCase10.java | 37 ++++
.../testset4/TestSet4_TestCase11.java | 59 ++++++
.../testset4/TestSet4_TestCase12.java | 54 +++++
.../testset4/TestSet4_TestCase13.java | 101 +++++++++
.../testset4/TestSet4_TestCase14.java | 58 ++++++
.../testset4/TestSet4_TestCase15.java | 103 ++++++++++
.../testset4/TestSet4_TestCase16.java | 76 +++++++
.../testset4/TestSet4_TestCase17.java | 114 +++++++++++
.../testset4/TestSet4_TestCase18.java | 36 ++++
.../testset4/TestSet4_TestCase19.java | 54 +++++
.../testset4/TestSet4_TestCase20.java | 49 +++++
.../testset5/TestSet5_TestCase01.java | 34 +++
.../testset5/TestSet5_TestCase02.java | 48 +++++
.../testset5/TestSet5_TestCase03.java | 43 ++++
.../testset5/TestSet5_TestCase04.java | 49 +++++
.../testset5/TestSet5_TestCase05.java | 50 +++++
.../testset5/TestSet5_TestCase06.java | 69 +++++++
.../testset5/TestSet5_TestCase07.java | 36 ++++
.../testset5/TestSet5_TestCase08.java | 36 ++++
.../testset5/TestSet5_TestCase09.java | 53 +++++
.../testset5/TestSet5_TestCase10.java | 31 +++
62 files changed, 3216 insertions(+), 2 deletions(-)
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/UnitTestDriver.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase01.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase02.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase03.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase04.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase05.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase06.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase07.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase08.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase09.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase10.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase01.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase02.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase03.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase04.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase05.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase06.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase07.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase08.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase09.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase10.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase01.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase02.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase03.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase04.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase05.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase06.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase07.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase08.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase09.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase10.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase01.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase02.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase03.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase04.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase05.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase06.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase07.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase08.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase09.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase10.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase11.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase12.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase13.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase14.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase15.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase16.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase17.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase18.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase19.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase20.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase01.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase02.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase03.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase04.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase05.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase06.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase07.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase08.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase09.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase10.java
diff --git a/.gitignore b/.gitignore
index 5cf5b5d..b12591b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
/LeetcodeJavaDebugEnhancer.iml
/target/
-/.idea/
-/src/test/
+/.idea/
\ No newline at end of file
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/UnitTestDriver.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/UnitTestDriver.java
new file mode 100644
index 0000000..616cd11
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/UnitTestDriver.java
@@ -0,0 +1,193 @@
+package io.github.jidcoo.opto.lcdb.enhancer;
+
+import io.github.jidcoo.opto.lcdb.enhancer.base.OutputConsumer;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.MultipleOutputConsumer;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+@RunWith(JUnit4.class)
+public abstract class UnitTestDriver extends LeetcodeJavaDebugEnhancer {
+
+ private static final UnitTestOutputCollector __GLOBAL__OC__ = new UnitTestOutputCollector();
+
+ private final static Lock __GLOBAL__SYS_STD_IN_CHANEL_LOCK__ = new ReentrantLock();
+
+ private final static InputStream __GLOBAL__SYS_STD_IN_HOLDER__ = System.in;
+
+ private final String __UNIT_TEST_ID__ = UUID.randomUUID().toString();
+
+ private String __TEST_EXPECTED_RESULT__;
+
+ private InputStream __CUSTOM_STD_IN_HOLDER__;
+
+ private boolean __IS__REGISTERED__;
+
+ private boolean __IS__IGNORED__OUTPUT__;
+
+ @Before
+ public final void __PROCESS_BEFORE_ON_DRIVER__() {
+ __GLOBAL__OC__.attach(this);
+ }
+
+ @After
+ public final void __PROCESS_AFTER_ON_DRIVER__() {
+ __GLOBAL__OC__.detach(this);
+ if (__CUSTOM_STD_IN_HOLDER__ != null) {
+ try {
+ __CUSTOM_STD_IN_HOLDER__.close();
+ } catch (IOException ignored) {
+ }
+ __CUSTOM_STD_IN_HOLDER__ = null;
+ System.setIn(__GLOBAL__SYS_STD_IN_HOLDER__);
+ __GLOBAL__SYS_STD_IN_CHANEL_LOCK__.unlock();
+ }
+ }
+
+ @Test
+ public final void __PROCESS_TEST_ON_DRIVER__() {
+ Assert.assertTrue(__IS__REGISTERED__);
+ LeetcodeJavaDebugEnhancer.main(null);
+ if (__IS__IGNORED__OUTPUT__) {
+ return;
+ }
+ Assert.assertEquals(__TEST_EXPECTED_RESULT__, __GLOBAL__OC__.collectOutput(this));
+ }
+
+ @Override
+ public OutputConsumer getOutputConsumer() {
+ OutputConsumer originOutputConsumer = super.getOutputConsumer();
+ List outputConsumers = new ArrayList<>();
+ outputConsumers.add(__GLOBAL__OC__);
+ if (originOutputConsumer != null) {
+ outputConsumers.add(originOutputConsumer);
+ }
+ return new MultipleOutputConsumer(outputConsumers);
+ }
+
+ protected final void ignoreTestResult() {
+ if (!__IS__IGNORED__OUTPUT__) {
+ __IS__IGNORED__OUTPUT__ = true;
+ }
+ }
+
+ protected final void expectString(String... expectedResult) {
+ if (__IS__IGNORED__OUTPUT__) {
+ return;
+ }
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < expectedResult.length; i++) {
+ if (i > 0) {
+ buf.append("\n");
+ }
+ buf.append(expectedResult[i]);
+ }
+ __TEST_EXPECTED_RESULT__ = buf.toString();
+ }
+
+ protected final void registerDriver() {
+ if (!__IS__REGISTERED__) {
+ System.setProperty("sun.java.command", this.getClass().getName());
+ __IS__REGISTERED__ = true;
+ }
+ }
+
+ protected final void registerDriverWithAutoCustomStdIn(String... stdIn) {
+ Assert.assertNotNull(stdIn);
+ if (stdIn.length == 0) {
+ registerDriver();
+ } else {
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < stdIn.length; i++) {
+ if (i > 0) {
+ buf.append("\n");
+ }
+ buf.append(stdIn[i]);
+ }
+ if (!__IS__REGISTERED__) {
+ ByteArrayInputStream in = new ByteArrayInputStream(buf.toString().getBytes());
+ __GLOBAL__SYS_STD_IN_CHANEL_LOCK__.lock();
+ __CUSTOM_STD_IN_HOLDER__ = in;
+ System.setIn(__CUSTOM_STD_IN_HOLDER__);
+ registerDriver();
+ }
+ }
+
+ }
+
+ private static class UnitTestOutputCollector implements OutputConsumer {
+
+ private final Map UNITTEST_OUTPUT_POOL;
+
+ private final ThreadLocal UNITTEST_INSTANCE_REGISTRY;
+
+ UnitTestOutputCollector() {
+ UNITTEST_OUTPUT_POOL = new ConcurrentHashMap<>();
+ UNITTEST_INSTANCE_REGISTRY = new InheritableThreadLocal<>();
+ }
+
+ void attach(UnitTestDriver driver) {
+ Assert.assertNotNull(driver);
+ Assert.assertNotNull(driver.__UNIT_TEST_ID__);
+ Assert.assertEquals(false, UNITTEST_OUTPUT_POOL.containsKey(driver.__UNIT_TEST_ID__));
+ Assert.assertNull(UNITTEST_INSTANCE_REGISTRY.get());
+ UNITTEST_INSTANCE_REGISTRY.set(driver.__UNIT_TEST_ID__);
+ UNITTEST_OUTPUT_POOL.put(driver.__UNIT_TEST_ID__, new StringBuffer());
+ }
+
+ void detach(UnitTestDriver driver) {
+ UNITTEST_INSTANCE_REGISTRY.remove();
+ Assert.assertNotNull(driver);
+ Assert.assertNotNull(driver.__UNIT_TEST_ID__);
+ StringBuffer output = UNITTEST_OUTPUT_POOL.remove(driver.__UNIT_TEST_ID__);
+ if (output != null) {
+ output.delete(0, output.length());
+ }
+ }
+
+ String collectOutput(UnitTestDriver driver) {
+ Assert.assertNotNull(driver);
+ Assert.assertNotNull(driver.__UNIT_TEST_ID__);
+ Assert.assertEquals(true, UNITTEST_OUTPUT_POOL.containsKey(driver.__UNIT_TEST_ID__));
+ Assert.assertNotNull(UNITTEST_INSTANCE_REGISTRY.get());
+ Assert.assertEquals(driver.__UNIT_TEST_ID__, UNITTEST_INSTANCE_REGISTRY.get());
+ StringBuffer output = UNITTEST_OUTPUT_POOL.get(driver.__UNIT_TEST_ID__);
+ Assert.assertNotNull(output);
+ String ret = output.toString();
+ output.delete(0, ret.length());
+ Assert.assertEquals(driver.__UNIT_TEST_ID__, UNITTEST_INSTANCE_REGISTRY.get());
+ return ret;
+ }
+
+ @Override
+ public void consumeNextOutput(String output) {
+ String unitTestInstance = UNITTEST_INSTANCE_REGISTRY.get();
+ Assert.assertNotNull(unitTestInstance);
+ Assert.assertEquals(true, UNITTEST_OUTPUT_POOL.containsKey(unitTestInstance));
+ StringBuffer outputBuffer = UNITTEST_OUTPUT_POOL.get(unitTestInstance);
+ if (outputBuffer.length() > 0) {
+ outputBuffer.append("\n");
+ }
+ outputBuffer.append(output);
+ }
+
+ @Override
+ public void close() throws Exception {
+
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase01.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase01.java
new file mode 100644
index 0000000..c329a96
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase01.java
@@ -0,0 +1,27 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet1_TestCase01 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[2,7,11,15] 9", "[3,2,4] 6", "[3,3] 6");
+ expectString("[0,1]", "[1,2]", "[0,1]");
+ }
+
+ class Solution {
+ public int[] twoSum(int[] nums, int target) {
+ int n = nums.length;
+ for (int i = 0; i < n; ++i) {
+ for (int j = i + 1; j < n; ++j) {
+ if (nums[i] + nums[j] == target) {
+ return new int[]{i, j};
+ }
+ }
+ }
+ return new int[0];
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase02.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase02.java
new file mode 100644
index 0000000..44a6172
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase02.java
@@ -0,0 +1,31 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
+import org.junit.Before;
+
+@Require(types = StringInputProvider.class, values = "[2,7,11,15] 9")
+@Require(types = StringInputProvider.class, values = "[3,2,4] 6\n[3,3] 6")
+public class TestSet1_TestCase02 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriver();
+ expectString("[0,1]", "[1,2]", "[0,1]");
+ }
+
+ class Solution {
+ public int[] twoSum(int[] nums, int target) {
+ int n = nums.length;
+ for (int i = 0; i < n; ++i) {
+ for (int j = i + 1; j < n; ++j) {
+ if (nums[i] + nums[j] == target) {
+ return new int[]{i, j};
+ }
+ }
+ }
+ return new int[0];
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase03.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase03.java
new file mode 100644
index 0000000..a37558d
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase03.java
@@ -0,0 +1,31 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
+import org.junit.Before;
+
+@Require(types = StringInputProvider.class, values = "[2,7,11,15] 9")
+@Require(types = StringInputProvider.class, values = {"[3,2,4] 6", "[3,3] 6"})
+public class TestSet1_TestCase03 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriver();
+ expectString("[0,1]", "[1,2]", "[0,1]");
+ }
+
+ class Solution {
+ public int[] twoSum(int[] nums, int target) {
+ int n = nums.length;
+ for (int i = 0; i < n; ++i) {
+ for (int j = i + 1; j < n; ++j) {
+ if (nums[i] + nums[j] == target) {
+ return new int[]{i, j};
+ }
+ }
+ }
+ return new int[0];
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase04.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase04.java
new file mode 100644
index 0000000..c801ef2
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase04.java
@@ -0,0 +1,37 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
+import org.junit.Before;
+
+@Require(types = {
+ StringInputProvider.class,
+ StringInputProvider.class
+},
+ values = {
+ "[2,7,11,15] 9\n[3,2,4] 6",
+ "[3,3] 6"
+ })
+public class TestSet1_TestCase04 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriver();
+ expectString("[0,1]","[1,2]","[0,1]");
+ }
+
+ class Solution {
+ public int[] twoSum(int[] nums, int target) {
+ int n = nums.length;
+ for (int i = 0; i < n; ++i) {
+ for (int j = i + 1; j < n; ++j) {
+ if (nums[i] + nums[j] == target) {
+ return new int[]{i, j};
+ }
+ }
+ }
+ return new int[0];
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase05.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase05.java
new file mode 100644
index 0000000..952cf10
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase05.java
@@ -0,0 +1,23 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet1_TestCase05 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,2,3,4]", "[1,1,1,1,1]", "[3,1,2,10,1]");
+ expectString("[1,3,6,10]", "[1,2,3,4,5]", "[3,4,6,16,17]");
+ }
+
+ class Solution {
+ public int[] runningSum(int[] nums) {
+ int n = nums.length;
+ for (int i = 1; i < n; i++) {
+ nums[i] += nums[i - 1];
+ }
+ return nums;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase06.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase06.java
new file mode 100644
index 0000000..1af2614
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase06.java
@@ -0,0 +1,51 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class TestSet1_TestCase06 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[-1,0,1,2,-1,-4]", "[0,1,1]", "[0,0,0]");
+ expectString("[[-1,-1,2],[-1,0,1]]", "[]", "[[0,0,0]]");
+ }
+
+ class Solution {
+ public List> threeSum(int[] nums) {
+ int n = nums.length;
+ Arrays.sort(nums);
+ List> ans = new ArrayList>();
+ for (int first = 0; first < n; ++first) {
+ if (first > 0 && nums[first] == nums[first - 1]) {
+ continue;
+ }
+ int third = n - 1;
+ int target = -nums[first];
+ for (int second = first + 1; second < n; ++second) {
+ if (second > first + 1 && nums[second] == nums[second - 1]) {
+ continue;
+ }
+ while (second < third && nums[second] + nums[third] > target) {
+ --third;
+ }
+ if (second == third) {
+ break;
+ }
+ if (nums[second] + nums[third] == target) {
+ List list = new ArrayList();
+ list.add(nums[first]);
+ list.add(nums[second]);
+ list.add(nums[third]);
+ ans.add(list);
+ }
+ }
+ }
+ return ans;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase07.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase07.java
new file mode 100644
index 0000000..7b5ae74
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase07.java
@@ -0,0 +1,68 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet1_TestCase07 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,2,3,4]", "[4,2,3,15]");
+ expectString("6", "5");
+ }
+
+ class Solution {
+ final int[] PRIMES = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
+ final int NUM_MAX = 30;
+ final int MOD = 1000000007;
+
+ public int numberOfGoodSubsets(int[] nums) {
+ int[] freq = new int[NUM_MAX + 1];
+ for (int num : nums) {
+ ++freq[num];
+ }
+
+ int[] f = new int[1 << PRIMES.length];
+ f[0] = 1;
+ for (int i = 0; i < freq[1]; ++i) {
+ f[0] = f[0] * 2 % MOD;
+ }
+
+ for (int i = 2; i <= NUM_MAX; ++i) {
+ if (freq[i] == 0) {
+ continue;
+ }
+
+ int subset = 0, x = i;
+ boolean check = true;
+ for (int j = 0; j < PRIMES.length; ++j) {
+ int prime = PRIMES[j];
+ if (x % (prime * prime) == 0) {
+ check = false;
+ break;
+ }
+ if (x % prime == 0) {
+ subset |= (1 << j);
+ }
+ }
+ if (!check) {
+ continue;
+ }
+
+ // 动态规划
+ for (int mask = (1 << PRIMES.length) - 1; mask > 0; --mask) {
+ if ((mask & subset) == subset) {
+ f[mask] = (int) ((f[mask] + ((long) f[mask ^ subset]) * freq[i]) % MOD);
+ }
+ }
+ }
+
+ int ans = 0;
+ for (int mask = 1, maskMax = (1 << PRIMES.length); mask < maskMax; ++mask) {
+ ans = (ans + f[mask]) % MOD;
+ }
+
+ return ans;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase08.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase08.java
new file mode 100644
index 0000000..9b2c482
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase08.java
@@ -0,0 +1,34 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet1_TestCase08 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[[3,0,8,4],[2,4,5,7],[9,2,6,3],[0,3,1,0]]", "[[0,0,0],[0,0,0],[0,0,0]]");
+ expectString("35", "0");
+ }
+
+ class Solution {
+ public int maxIncreaseKeepingSkyline(int[][] grid) {
+ int n = grid.length;
+ int[] rowMax = new int[n];
+ int[] colMax = new int[n];
+ for (int i = 0; i < n; i++) {
+ for (int j = 0; j < n; j++) {
+ rowMax[i] = Math.max(rowMax[i], grid[i][j]);
+ colMax[j] = Math.max(colMax[j], grid[i][j]);
+ }
+ }
+ int ans = 0;
+ for (int i = 0; i < n; i++) {
+ for (int j = 0; j < n; j++) {
+ ans += Math.min(rowMax[i], colMax[j]) - grid[i][j];
+ }
+ }
+ return ans;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase09.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase09.java
new file mode 100644
index 0000000..8ad1605
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase09.java
@@ -0,0 +1,67 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestSet1_TestCase09 extends UnitTestDriver {
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]]",
+ "[[2,1],[1,2]]");
+ expectString("[[0,4],[1,3],[1,4],[2,2],[3,0],[3,1],[4,0]]", "[[0,0],[0,1],[1,0],[1,1]]");
+ }
+
+ class Solution {
+ int[][] dirs = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
+ int[][] heights;
+ int m, n;
+
+ public List> pacificAtlantic(int[][] heights) {
+ this.heights = heights;
+ this.m = heights.length;
+ this.n = heights[0].length;
+ boolean[][] pacific = new boolean[m][n];
+ boolean[][] atlantic = new boolean[m][n];
+ for (int i = 0; i < m; i++) {
+ dfs(i, 0, pacific);
+ }
+ for (int j = 1; j < n; j++) {
+ dfs(0, j, pacific);
+ }
+ for (int i = 0; i < m; i++) {
+ dfs(i, n - 1, atlantic);
+ }
+ for (int j = 0; j < n - 1; j++) {
+ dfs(m - 1, j, atlantic);
+ }
+ List> result = new ArrayList>();
+ for (int i = 0; i < m; i++) {
+ for (int j = 0; j < n; j++) {
+ if (pacific[i][j] && atlantic[i][j]) {
+ List cell = new ArrayList();
+ cell.add(i);
+ cell.add(j);
+ result.add(cell);
+ }
+ }
+ }
+ return result;
+ }
+
+ public void dfs(int row, int col, boolean[][] ocean) {
+ if (ocean[row][col]) {
+ return;
+ }
+ ocean[row][col] = true;
+ for (int[] dir : dirs) {
+ int newRow = row + dir[0], newCol = col + dir[1];
+ if (newRow >= 0 && newRow < m && newCol >= 0 && newCol < n && heights[newRow][newCol] >= heights[row][col]) {
+ dfs(newRow, newCol, ocean);
+ }
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase10.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase10.java
new file mode 100644
index 0000000..abeb306
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase10.java
@@ -0,0 +1,33 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+public class TestSet1_TestCase10 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,1,1,1,1,null,1]","[2,2,2,5,2]");
+ expectString("true", "false");
+ }
+
+ class Solution {
+ public boolean isUnivalTree(TreeNode root) {
+ if (root == null) {
+ return true;
+ }
+ if (root.left != null) {
+ if (root.val != root.left.val || !isUnivalTree(root.left)) {
+ return false;
+ }
+ }
+ if (root.right != null) {
+ if (root.val != root.right.val || !isUnivalTree(root.right)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase01.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase01.java
new file mode 100644
index 0000000..459be01
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase01.java
@@ -0,0 +1,38 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
+import org.junit.Before;
+
+@Require(types = StringInputProvider.class, values = "[[1,1,1],[1,0,1],[1,1,1]]")
+public class TestSet2_TestCase01 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriver();
+ ignoreTestResult();
+ }
+
+ class Solution {
+ public void setZeroes(int[][] matrix) {
+ int m = matrix.length, n = matrix[0].length;
+ boolean[] row = new boolean[m];
+ boolean[] col = new boolean[n];
+ for (int i = 0; i < m; i++) {
+ for (int j = 0; j < n; j++) {
+ if (matrix[i][j] == 0) {
+ row[i] = col[j] = true;
+ }
+ }
+ }
+ for (int i = 0; i < m; i++) {
+ for (int j = 0; j < n; j++) {
+ if (row[i] || col[j]) {
+ matrix[i][j] = 0;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase02.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase02.java
new file mode 100644
index 0000000..01d641f
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase02.java
@@ -0,0 +1,94 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
+import org.junit.Before;
+
+import java.util.*;
+
+@Require(types = StringInputProvider.class, values = {"\"hit\" \"cog\" [\"hot\",\"dot\",\"dog\",\"lot\",\"log\"," +
+ "\"cog\"]", "\"hit\" \"cog\" [\"hot\",\"dot\",\"dog\",\"lot\",\"log\"]"})
+public class TestSet2_TestCase02 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriver();
+ expectString("[[\"hit\",\"hot\",\"dot\",\"dog\",\"cog\"],[\"hit\",\"hot\",\"lot\",\"log\",\"cog\"]]", "[]");
+ }
+
+ class Solution {
+ public List> findLadders(String beginWord, String endWord, List wordList) {
+ List> res = new ArrayList<>();
+ Set dict = new HashSet<>(wordList);
+ if (!dict.contains(endWord)) {
+ return res;
+ }
+
+ dict.remove(beginWord);
+
+ Map steps = new HashMap();
+ steps.put(beginWord, 0);
+ Map> from = new HashMap>();
+ int step = 1;
+ boolean found = false;
+ int wordLen = beginWord.length();
+ Queue queue = new ArrayDeque();
+ queue.offer(beginWord);
+ while (!queue.isEmpty()) {
+ int size = queue.size();
+ for (int i = 0; i < size; i++) {
+ String currWord = queue.poll();
+ char[] charArray = currWord.toCharArray();
+ for (int j = 0; j < wordLen; j++) {
+ char origin = charArray[j];
+ for (char c = 'a'; c <= 'z'; c++) {
+ charArray[j] = c;
+ String nextWord = String.valueOf(charArray);
+ if (steps.containsKey(nextWord) && step == steps.get(nextWord)) {
+ from.get(nextWord).add(currWord);
+ }
+ if (!dict.contains(nextWord)) {
+ continue;
+ }
+ dict.remove(nextWord);
+ queue.offer(nextWord);
+
+ from.putIfAbsent(nextWord, new ArrayList<>());
+ from.get(nextWord).add(currWord);
+ steps.put(nextWord, step);
+ if (nextWord.equals(endWord)) {
+ found = true;
+ }
+ }
+ charArray[j] = origin;
+ }
+ }
+ step++;
+ if (found) {
+ break;
+ }
+ }
+
+ if (found) {
+ Deque path = new ArrayDeque<>();
+ path.add(endWord);
+ backtrack(from, path, beginWord, endWord, res);
+ }
+ return res;
+ }
+
+ public void backtrack(Map> from, Deque path, String beginWord, String cur,
+ List> res) {
+ if (cur.equals(beginWord)) {
+ res.add(new ArrayList<>(path));
+ return;
+ }
+ for (String precursor : from.get(cur)) {
+ path.addFirst(precursor);
+ backtrack(from, path, beginWord, precursor, res);
+ path.removeFirst();
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase03.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase03.java
new file mode 100644
index 0000000..9323dfb
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase03.java
@@ -0,0 +1,25 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet2_TestCase03 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("2","3");
+ expectString("2","3");
+ }
+
+ class Solution {
+ public int climbStairs(int n) {
+ int p = 0, q = 0, r = 1;
+ for (int i = 1; i <= n; ++i) {
+ p = q;
+ q = r;
+ r = p + q;
+ }
+ return r;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase04.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase04.java
new file mode 100644
index 0000000..571a5dc
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase04.java
@@ -0,0 +1,42 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
+import org.junit.Before;
+
+@Require(types = StringInputProvider.class, values = {"[1,2,3]", "[-10,9,20,null,null,15,7]"})
+public class TestSet2_TestCase04 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriver();
+ expectString("6", "42");
+ }
+
+ class Solution {
+ int maxSum;
+
+ public int maxPathSum(TreeNode root) {
+ maxSum = Integer.MIN_VALUE;
+ maxGain(root);
+ return maxSum;
+ }
+
+ private int maxGain(TreeNode node) {
+ if (node == null) {
+ return 0;
+ }
+
+ int leftGain = Math.max(maxGain(node.left), 0);
+ int rightGain = Math.max(maxGain(node.right), 0);
+
+ int priceNewpath = node.val + leftGain + rightGain;
+
+ maxSum = Math.max(maxSum, priceNewpath);
+
+ return node.val + Math.max(leftGain, rightGain);
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase05.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase05.java
new file mode 100644
index 0000000..fcad24a
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase05.java
@@ -0,0 +1,47 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
+import org.junit.Before;
+
+import java.util.Arrays;
+
+@Require(types = StringInputProvider.class, values = {"2 [2,4,1]", "2 [3,2,6,5,0,3]"})
+public class TestSet2_TestCase05 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriver();
+ expectString("2", "7");
+ }
+
+ class Solution {
+ public int maxProfit(int k, int[] prices) {
+ if (prices.length == 0) {
+ return 0;
+ }
+
+ int n = prices.length;
+ k = Math.min(k, n / 2);
+ int[][] buy = new int[n][k + 1];
+ int[][] sell = new int[n][k + 1];
+
+ buy[0][0] = -prices[0];
+ sell[0][0] = 0;
+ for (int i = 1; i <= k; ++i) {
+ buy[0][i] = sell[0][i] = Integer.MIN_VALUE / 2;
+ }
+
+ for (int i = 1; i < n; ++i) {
+ buy[i][0] = Math.max(buy[i - 1][0], sell[i - 1][0] - prices[i]);
+ for (int j = 1; j <= k; ++j) {
+ buy[i][j] = Math.max(buy[i - 1][j], sell[i - 1][j] - prices[i]);
+ sell[i][j] = Math.max(sell[i - 1][j], buy[i - 1][j - 1] + prices[i]);
+ }
+ }
+
+ return Arrays.stream(sell[n - 1]).max().getAsInt();
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase06.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase06.java
new file mode 100644
index 0000000..9195523
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase06.java
@@ -0,0 +1,32 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
+import org.junit.Before;
+
+@Require(types = StringInputProvider.class, values = {"[10,5,15,3,7,null,18] 7 15", "[10,5,15,3,7,13,18,1,null,6] 6 10"})
+public class TestSet2_TestCase06 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriver();
+ expectString("32", "23");
+ }
+
+ class Solution {
+ public int rangeSumBST(TreeNode root, int low, int high) {
+ if (root == null) {
+ return 0;
+ }
+ if (root.val > high) {
+ return rangeSumBST(root.left, low, high);
+ }
+ if (root.val < low) {
+ return rangeSumBST(root.right, low, high);
+ }
+ return root.val + rangeSumBST(root.left, low, high) + rangeSumBST(root.right, low, high);
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase07.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase07.java
new file mode 100644
index 0000000..0ee496e
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase07.java
@@ -0,0 +1,39 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet2_TestCase07 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("\"aa\" \"a\"", "\"aa\" \"*\"", "\"cb\" \"?a\"");
+ expectString("false", "true", "false");
+ }
+
+ class Solution {
+ public boolean isMatch(String s, String p) {
+ int m = s.length();
+ int n = p.length();
+ boolean[][] dp = new boolean[m + 1][n + 1];
+ dp[0][0] = true;
+ for (int i = 1; i <= n; ++i) {
+ if (p.charAt(i - 1) == '*') {
+ dp[0][i] = true;
+ } else {
+ break;
+ }
+ }
+ for (int i = 1; i <= m; ++i) {
+ for (int j = 1; j <= n; ++j) {
+ if (p.charAt(j - 1) == '*') {
+ dp[i][j] = dp[i][j - 1] || dp[i - 1][j];
+ } else if (p.charAt(j - 1) == '?' || s.charAt(i - 1) == p.charAt(j - 1)) {
+ dp[i][j] = dp[i - 1][j - 1];
+ }
+ }
+ }
+ return dp[m][n];
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase08.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase08.java
new file mode 100644
index 0000000..717e5f7
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase08.java
@@ -0,0 +1,49 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestSet2_TestCase08 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn(
+ "[\"5\",\"2\",\"C\",\"D\",\"+\"]",
+ "[\"5\",\"-2\",\"4\",\"C\",\"D\",\"9\",\"+\",\"+\"]",
+ "[\"1\"]"
+ );
+ expectString("30", "27", "1");
+ }
+
+ class Solution {
+ public int calPoints(String[] ops) {
+ int ret = 0;
+ List points = new ArrayList();
+ for (String op : ops) {
+ int n = points.size();
+ switch (op.charAt(0)) {
+ case '+':
+ ret += points.get(n - 1) + points.get(n - 2);
+ points.add(points.get(n - 1) + points.get(n - 2));
+ break;
+ case 'D':
+ ret += 2 * points.get(n - 1);
+ points.add(2 * points.get(n - 1));
+ break;
+ case 'C':
+ ret -= points.get(n - 1);
+ points.remove(n - 1);
+ break;
+ default:
+ ret += Integer.parseInt(op);
+ points.add(Integer.parseInt(op));
+ break;
+ }
+ }
+ return ret;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase09.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase09.java
new file mode 100644
index 0000000..8a7d64b
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase09.java
@@ -0,0 +1,53 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.PriorityQueue;
+
+public class TestSet2_TestCase09 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[[4,10,15,24,26], [0,9,12,20], [5,18,22,30]]", "[[1,2,3],[1,2,3],[1,2,3]]");
+ expectString("[20,24]", "[1,1]");
+ }
+
+ class Solution {
+ public int[] smallestRange(List> nums) {
+ int rangeLeft = 0, rangeRight = Integer.MAX_VALUE;
+ int minRange = rangeRight - rangeLeft;
+ int max = Integer.MIN_VALUE;
+ int size = nums.size();
+ int[] next = new int[size];
+ PriorityQueue priorityQueue = new PriorityQueue(new Comparator() {
+ public int compare(Integer index1, Integer index2) {
+ return nums.get(index1).get(next[index1]) - nums.get(index2).get(next[index2]);
+ }
+ });
+ for (int i = 0; i < size; i++) {
+ priorityQueue.offer(i);
+ max = Math.max(max, nums.get(i).get(0));
+ }
+ while (true) {
+ int minIndex = priorityQueue.poll();
+ int curRange = max - nums.get(minIndex).get(next[minIndex]);
+ if (curRange < minRange) {
+ minRange = curRange;
+ rangeLeft = nums.get(minIndex).get(next[minIndex]);
+ rangeRight = max;
+ }
+ next[minIndex]++;
+ if (next[minIndex] == nums.get(minIndex).size()) {
+ break;
+ }
+ priorityQueue.offer(minIndex);
+ max = Math.max(max, nums.get(minIndex).get(next[minIndex]));
+ }
+ return new int[]{rangeLeft, rangeRight};
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase10.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase10.java
new file mode 100644
index 0000000..fbe980b
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase10.java
@@ -0,0 +1,42 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TestSet2_TestCase10 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("\"this apple is sweet\" \"this apple is sour\"",
+ "\"apple apple\" \"banana\"");
+ expectString("[\"sweet\",\"sour\"]", "[\"banana\"]");
+ }
+
+ class Solution {
+ public String[] uncommonFromSentences(String s1, String s2) {
+ Map freq = new HashMap();
+ insert(s1, freq);
+ insert(s2, freq);
+
+ List ans = new ArrayList();
+ for (Map.Entry entry : freq.entrySet()) {
+ if (entry.getValue() == 1) {
+ ans.add(entry.getKey());
+ }
+ }
+ return ans.toArray(new String[0]);
+ }
+
+ public void insert(String s, Map freq) {
+ String[] arr = s.split(" ");
+ for (String word : arr) {
+ freq.put(word, freq.getOrDefault(word, 0) + 1);
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase01.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase01.java
new file mode 100644
index 0000000..60145b8
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase01.java
@@ -0,0 +1,34 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import org.junit.Before;
+
+public class TestSet3_TestCase01 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,2,3,4,5] 2", "[1] 1", "[1,2] 1");
+ expectString("[1,2,3,5]", "[]", "[1]");
+ }
+
+ class Solution {
+ public ListNode removeNthFromEnd(ListNode head, int n) {
+ int i = 0;
+ ListNode fast = head;
+ while (i < n) {
+ fast = fast.next;
+ ++i;
+ }
+ ListNode last;
+ ListNode dummy = new ListNode(0, head);
+ ListNode slow = dummy;
+ while (fast != null) {
+ fast = fast.next;
+ slow = slow.next;
+ }
+ slow.next = slow.next.next;
+ return dummy.next;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase02.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase02.java
new file mode 100644
index 0000000..b125bbd
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase02.java
@@ -0,0 +1,55 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import org.junit.Before;
+
+public class TestSet3_TestCase02 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,2,3,4,5] 2 4", "[5] 1 1");
+ expectString("[1,4,3,2,5]", "[5]");
+ }
+
+ class Solution {
+ public ListNode reverseBetween(ListNode head, int left, int right) {
+ ListNode dummyNode = new ListNode(-1);
+ dummyNode.next = head;
+
+ ListNode pre = dummyNode;
+ for (int i = 0; i < left - 1; i++) {
+ pre = pre.next;
+ }
+
+ ListNode rightNode = pre;
+ for (int i = 0; i < right - left + 1; i++) {
+ rightNode = rightNode.next;
+ }
+
+ ListNode leftNode = pre.next;
+ ListNode curr = rightNode.next;
+
+ pre.next = null;
+ rightNode.next = null;
+
+ reverseLinkedList(leftNode);
+
+ pre.next = rightNode;
+ leftNode.next = curr;
+ return dummyNode.next;
+ }
+
+ private void reverseLinkedList(ListNode head) {
+ ListNode pre = null;
+ ListNode cur = head;
+
+ while (cur != null) {
+ ListNode next = cur.next;
+ cur.next = pre;
+ pre = cur;
+ cur = next;
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase03.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase03.java
new file mode 100644
index 0000000..be06d84
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase03.java
@@ -0,0 +1,40 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import org.junit.Before;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class TestSet3_TestCase03 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[0,1,2,3] [0,1,3]", "[0,1,2,3,4] [0,3,1,4]");
+ expectString("2", "2");
+ }
+
+ class Solution {
+ public int numComponents(ListNode head, int[] nums) {
+ Set numsSet = new HashSet();
+ for (int num : nums) {
+ numsSet.add(num);
+ }
+ boolean inSet = false;
+ int res = 0;
+ while (head != null) {
+ if (numsSet.contains(head.val)) {
+ if (!inSet) {
+ inSet = true;
+ res++;
+ }
+ } else {
+ inSet = false;
+ }
+ head = head.next;
+ }
+ return res;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase04.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase04.java
new file mode 100644
index 0000000..6e575c6
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase04.java
@@ -0,0 +1,36 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import org.junit.Before;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class TestSet3_TestCase04 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,2,3] [1,2,3,4,5]", "[1] [1,2,1,2,1,2]", "[5] [1,2,3,4]");
+ expectString("[4,5]", "[2,2,2]", "[1,2,3,4]");
+ }
+
+ class Solution {
+ public ListNode modifiedList(int[] nums, ListNode head) {
+ Set set = new HashSet<>(nums.length);
+ for (int x : nums) {
+ set.add(x);
+ }
+ ListNode dummy = new ListNode(0, head);
+ ListNode cur = dummy;
+ while (cur.next != null) {
+ if (set.contains(cur.next.val)) {
+ cur.next = cur.next.next;
+ } else {
+ cur = cur.next;
+ }
+ }
+ return dummy.next;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase05.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase05.java
new file mode 100644
index 0000000..28a34c4
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase05.java
@@ -0,0 +1,45 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import org.junit.Before;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+
+public class TestSet3_TestCase05 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[7,2,4,3] [5,6,4]", "[2,4,3] [5,6,4]", "[0] [0]");
+ expectString("[7,8,0,7]", "[8,0,7]", "[0]");
+ }
+
+ class Solution {
+ public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
+ Deque stack1 = new ArrayDeque();
+ Deque stack2 = new ArrayDeque();
+ while (l1 != null) {
+ stack1.push(l1.val);
+ l1 = l1.next;
+ }
+ while (l2 != null) {
+ stack2.push(l2.val);
+ l2 = l2.next;
+ }
+ int carry = 0;
+ ListNode ans = null;
+ while (!stack1.isEmpty() || !stack2.isEmpty() || carry != 0) {
+ int a = stack1.isEmpty() ? 0 : stack1.pop();
+ int b = stack2.isEmpty() ? 0 : stack2.pop();
+ int cur = a + b + carry;
+ carry = cur / 10;
+ cur %= 10;
+ ListNode curnode = new ListNode(cur);
+ curnode.next = ans;
+ ans = curnode;
+ }
+ return ans;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase06.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase06.java
new file mode 100644
index 0000000..0ce1878
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase06.java
@@ -0,0 +1,45 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import org.junit.Before;
+
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.List;
+
+public class TestSet3_TestCase06 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[2,1,5]", "[2,7,4,3,5]");
+ expectString("[5,5,0]", "[7,0,5,5,0]");
+ }
+
+ class Solution {
+ public int[] nextLargerNodes(ListNode head) {
+ List ans = new ArrayList();
+ Deque stack = new ArrayDeque();
+
+ ListNode cur = head;
+ int idx = -1;
+ while (cur != null) {
+ ++idx;
+ ans.add(0);
+ while (!stack.isEmpty() && stack.peek()[0] < cur.val) {
+ ans.set(stack.pop()[1], cur.val);
+ }
+ stack.push(new int[]{cur.val, idx});
+ cur = cur.next;
+ }
+
+ int size = ans.size();
+ int[] arr = new int[size];
+ for (int i = 0; i < size; ++i) {
+ arr[i] = ans.get(i);
+ }
+ return arr;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase07.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase07.java
new file mode 100644
index 0000000..e66eb4e
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase07.java
@@ -0,0 +1,54 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+import java.util.*;
+
+public class TestSet3_TestCase07 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,2,3,4,5,null,7,8]");
+ ignoreTestResult();
+ }
+
+ class Solution {
+ public ListNode[] listOfDepth(TreeNode tree) {
+ Queue queue = new LinkedList<>();
+ List> lists = new ArrayList<>();
+ if (tree != null) {
+ queue.add(tree);
+ }
+ while (!queue.isEmpty()) {
+ List list = new ArrayList<>();
+ for (int i = queue.size(); i > 0; i--) {
+ TreeNode tmp = queue.poll();
+ list.add(tmp.val);
+ if (tmp.left != null) {
+ queue.add(tmp.left);
+ }
+ if (tmp.right != null) {
+ queue.add(tmp.right);
+ }
+ }
+ lists.add(list);
+ }
+ ListNode[] a = new ListNode[lists.size()];
+
+ for (int i = 0; i < lists.size(); i++) {
+ ListNode l = new ListNode(0);
+ ListNode ll = l;
+ for (int j = 0; j < lists.get(i).size(); j++) {
+ ListNode tmp = new ListNode(lists.get(i).get(j));
+ l.next = tmp;
+ l = l.next;
+ }
+ a[i] = ll.next;
+ }
+ return a;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase08.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase08.java
new file mode 100644
index 0000000..cb354ee
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase08.java
@@ -0,0 +1,34 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import org.junit.Before;
+
+public class TestSet3_TestCase08 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[5,4,2,1]", "[4,2,2,3]", "[1,100000]");
+ expectString("6", "7", "100001");
+ }
+
+ class Solution {
+ public int pairSum(ListNode head) {
+ ListNode prev = null, curr = head, last = head;
+ while (last != null) {
+ last = last.next.next;
+ ListNode temp = curr.next;
+ curr.next = prev;
+ prev = curr;
+ curr = temp;
+ }
+ int max = 0;
+ while (curr != null) {
+ max = Math.max(max, prev.val + curr.val);
+ prev = prev.next;
+ curr = curr.next;
+ }
+ return max;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase09.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase09.java
new file mode 100644
index 0000000..394c9e8
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase09.java
@@ -0,0 +1,34 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import org.junit.Before;
+
+public class TestSet3_TestCase09 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[0,3,1,0,4,5,2,0]");
+ expectString("[4,11]");
+ }
+
+ class Solution {
+ public ListNode mergeNodes(ListNode head) {
+ ListNode dummy = new ListNode();
+ ListNode tail = dummy;
+ int total = 0;
+ for (ListNode cur = head.next; cur != null; cur = cur.next) {
+ if (cur.val == 0) {
+ ListNode node = new ListNode(total);
+ tail.next = node;
+ tail = tail.next;
+ total = 0;
+ } else {
+ total += cur.val;
+ }
+ }
+
+ return dummy.next;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase10.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase10.java
new file mode 100644
index 0000000..022d736
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase10.java
@@ -0,0 +1,40 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import org.junit.Before;
+
+
+public class TestSet3_TestCase10 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,2,3,4,5] 2");
+ expectString("[4,5,1,2,3]");
+ }
+
+ class Solution {
+ public ListNode rotateRight(ListNode head, int k) {
+ if (k == 0 || head == null || head.next == null) {
+ return head;
+ }
+ int n = 1;
+ ListNode iter = head;
+ while (iter.next != null) {
+ iter = iter.next;
+ n++;
+ }
+ int add = n - k % n;
+ if (add == n) {
+ return head;
+ }
+ iter.next = head;
+ while (add-- > 0) {
+ iter = iter.next;
+ }
+ ListNode ret = iter.next;
+ iter.next = null;
+ return ret;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase01.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase01.java
new file mode 100644
index 0000000..b6f45a2
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase01.java
@@ -0,0 +1,103 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.ConsoleInputProvider;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.ConsoleOutputConsumer;
+import org.junit.Before;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Require(types = ConsoleInputProvider.class)
+@Require(types = ConsoleOutputConsumer.class)
+public class TestSet4_TestCase01 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"LRUCache\", \"put\", \"put\", \"get\", \"put\", \"get\", \"put\", " +
+ "\"get\", \"get\", \"get\"] " +
+ "[[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]]");
+ expectString("[null,null,null,1,null,-1,null,-1,3,4]");
+ }
+
+ class LRUCache {
+ private Map cache = new HashMap();
+ private int size;
+ private int capacity;
+ private DLinkedNode head, tail;
+ public LRUCache(int capacity) {
+ this.size = 0;
+ this.capacity = capacity;
+ head = new DLinkedNode();
+ tail = new DLinkedNode();
+ head.next = tail;
+ tail.prev = head;
+ }
+
+ public int get(int key) {
+ DLinkedNode node = cache.get(key);
+ if (node == null) {
+ return -1;
+ }
+ moveToHead(node);
+ return node.value;
+ }
+
+ public void put(int key, int value) {
+ DLinkedNode node = cache.get(key);
+ if (node == null) {
+ DLinkedNode newNode = new DLinkedNode(key, value);
+ cache.put(key, newNode);
+ addToHead(newNode);
+ ++size;
+ if (size > capacity) {
+ DLinkedNode tail = removeTail();
+ cache.remove(tail.key);
+ --size;
+ }
+ } else {
+ node.value = value;
+ moveToHead(node);
+ }
+ }
+
+ private void addToHead(DLinkedNode node) {
+ node.prev = head;
+ node.next = head.next;
+ head.next.prev = node;
+ head.next = node;
+ }
+
+ private void removeNode(DLinkedNode node) {
+ node.prev.next = node.next;
+ node.next.prev = node.prev;
+ }
+
+ private void moveToHead(DLinkedNode node) {
+ removeNode(node);
+ addToHead(node);
+ }
+
+ private DLinkedNode removeTail() {
+ DLinkedNode res = tail.prev;
+ removeNode(res);
+ return res;
+ }
+
+ class DLinkedNode {
+ int key;
+ int value;
+ DLinkedNode prev;
+ DLinkedNode next;
+
+ public DLinkedNode() {
+ }
+
+ public DLinkedNode(int _key, int _value) {
+ key = _key;
+ value = _value;
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase02.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase02.java
new file mode 100644
index 0000000..7448347
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase02.java
@@ -0,0 +1,46 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.Deque;
+import java.util.LinkedList;
+
+public class TestSet4_TestCase02 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"MinStack\",\"push\",\"push\",\"push\",\"getMin\",\"pop\",\"top\"," +
+ "\"getMin\"] [[],[-2],[0],[-3],[],[],[],[]]");
+ expectString("[null,null,null,null,-3,null,0,-2]");
+ }
+
+ class MinStack {
+ Deque xStack;
+ Deque minStack;
+
+ public MinStack() {
+ xStack = new LinkedList();
+ minStack = new LinkedList();
+ minStack.push(Integer.MAX_VALUE);
+ }
+
+ public void push(int x) {
+ xStack.push(x);
+ minStack.push(Math.min(minStack.peek(), x));
+ }
+
+ public void pop() {
+ xStack.pop();
+ minStack.pop();
+ }
+
+ public int top() {
+ return xStack.peek();
+ }
+
+ public int getMin() {
+ return minStack.peek();
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase03.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase03.java
new file mode 100644
index 0000000..a149ced
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase03.java
@@ -0,0 +1,86 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet4_TestCase03 extends UnitTestDriver {
+
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"WordDictionary\",\"addWord\",\"addWord\",\"addWord\",\"search\"," +
+ "\"search\",\"search\",\"search\"] [[],[\"bad\"],[\"dad\"],[\"mad\"],[\"pad\"],[\"bad\"],[\".ad\"]," +
+ "[\"b..\"]]");
+ expectString("[null,null,null,null,false,true,true,true]");
+ }
+
+ class WordDictionary {
+ private Trie root;
+
+ public WordDictionary() {
+ root = new Trie();
+ }
+
+ public void addWord(String word) {
+ root.insert(word);
+ }
+
+ public boolean search(String word) {
+ return dfs(word, 0, root);
+ }
+
+ private boolean dfs(String word, int index, Trie node) {
+ if (index == word.length()) {
+ return node.isEnd();
+ }
+ char ch = word.charAt(index);
+ if (Character.isLetter(ch)) {
+ int childIndex = ch - 'a';
+ Trie child = node.getChildren()[childIndex];
+ if (child != null && dfs(word, index + 1, child)) {
+ return true;
+ }
+ } else {
+ for (int i = 0; i < 26; i++) {
+ Trie child = node.getChildren()[i];
+ if (child != null && dfs(word, index + 1, child)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+ class Trie {
+ private Trie[] children;
+ private boolean isEnd;
+
+ public Trie() {
+ children = new Trie[26];
+ isEnd = false;
+ }
+
+ public void insert(String word) {
+ Trie node = this;
+ for (int i = 0; i < word.length(); i++) {
+ char ch = word.charAt(i);
+ int index = ch - 'a';
+ if (node.children[index] == null) {
+ node.children[index] = new Trie();
+ }
+ node = node.children[index];
+ }
+ node.isEnd = true;
+ }
+
+ public Trie[] getChildren() {
+ return children;
+ }
+
+ public boolean isEnd() {
+ return isEnd;
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase04.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase04.java
new file mode 100644
index 0000000..933dec8
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase04.java
@@ -0,0 +1,30 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet4_TestCase04 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"NumArray\", \"sumRange\", \"sumRange\", \"sumRange\"] [[[-2, 0, 3, -5, " +
+ "2, -1]], [0, 2], [2, 5], [0, 5]]");
+ expectString("[null,1,-1,-3]");
+ }
+
+ class NumArray {
+ int[] sums;
+
+ public NumArray(int[] nums) {
+ int n = nums.length;
+ sums = new int[n + 1];
+ for (int i = 0; i < n; i++) {
+ sums[i + 1] = sums[i] + nums[i];
+ }
+ }
+
+ public int sumRange(int i, int j) {
+ return sums[j + 1] - sums[i];
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase05.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase05.java
new file mode 100644
index 0000000..d28a426
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase05.java
@@ -0,0 +1,39 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet4_TestCase05 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"NumMatrix\",\"sumRegion\",\"sumRegion\",\"sumRegion\"] [[[[3,0,1,4,2]," +
+ "[5,6,3,2,1],[1,2,0,1,5],[4,1,0,1,7],[1,0,3,0,5]]],[2,1,4,3],[1,1,2,2],[1,2,2,4]]");
+ expectString("[null,8,11,12]");
+ }
+
+ class NumMatrix {
+ int[][] sums;
+
+ public NumMatrix(int[][] matrix) {
+ int m = matrix.length;
+ if (m > 0) {
+ int n = matrix[0].length;
+ sums = new int[m][n + 1];
+ for (int i = 0; i < m; i++) {
+ for (int j = 0; j < n; j++) {
+ sums[i][j + 1] = sums[i][j] + matrix[i][j];
+ }
+ }
+ }
+ }
+
+ public int sumRegion(int row1, int col1, int row2, int col2) {
+ int sum = 0;
+ for (int i = row1; i <= row2; i++) {
+ sum += sums[i][col2 + 1] - sums[i][col1];
+ }
+ return sum;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase06.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase06.java
new file mode 100644
index 0000000..f09870a
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase06.java
@@ -0,0 +1,72 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet4_TestCase06 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"NumArray\", \"sumRange\", \"update\", \"sumRange\"] [[[1, 3, 5]], [0, " +
+ "2], [1, 2], [0, 2]]");
+ expectString("[null,9,null,8]");
+ }
+
+ class NumArray {
+ private int[] segmentTree;
+ private int n;
+
+ public NumArray(int[] nums) {
+ n = nums.length;
+ segmentTree = new int[nums.length * 4];
+ build(0, 0, n - 1, nums);
+ }
+
+ public void update(int index, int val) {
+ change(index, val, 0, 0, n - 1);
+ }
+
+ public int sumRange(int left, int right) {
+ return range(left, right, 0, 0, n - 1);
+ }
+
+ private void build(int node, int s, int e, int[] nums) {
+ if (s == e) {
+ segmentTree[node] = nums[s];
+ return;
+ }
+ int m = s + (e - s) / 2;
+ build(node * 2 + 1, s, m, nums);
+ build(node * 2 + 2, m + 1, e, nums);
+ segmentTree[node] = segmentTree[node * 2 + 1] + segmentTree[node * 2 + 2];
+ }
+
+ private void change(int index, int val, int node, int s, int e) {
+ if (s == e) {
+ segmentTree[node] = val;
+ return;
+ }
+ int m = s + (e - s) / 2;
+ if (index <= m) {
+ change(index, val, node * 2 + 1, s, m);
+ } else {
+ change(index, val, node * 2 + 2, m + 1, e);
+ }
+ segmentTree[node] = segmentTree[node * 2 + 1] + segmentTree[node * 2 + 2];
+ }
+
+ private int range(int left, int right, int node, int s, int e) {
+ if (left == s && right == e) {
+ return segmentTree[node];
+ }
+ int m = s + (e - s) / 2;
+ if (right <= m) {
+ return range(left, right, node * 2 + 1, s, m);
+ } else if (left > m) {
+ return range(left, right, node * 2 + 2, m + 1, e);
+ } else {
+ return range(left, m, node * 2 + 1, s, m) + range(m + 1, right, node * 2 + 2, m + 1, e);
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase07.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase07.java
new file mode 100644
index 0000000..04db4e7
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase07.java
@@ -0,0 +1,89 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
+import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
+import org.junit.Before;
+
+@Require(types = StringInputProvider.class,
+ values = "[\"MyCircularDeque\", \"insertLast\", \"insertLast\", \"insertFront\", \"insertFront\", " +
+ "\"getRear\", " +
+ "\"isFull\", \"deleteLast\", \"insertFront\", \"getFront\"] [[3], [1], [2], [3], [4], [], [], [], " +
+ "[4], []]")
+
+public class TestSet4_TestCase07 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriver();
+ expectString("[null,true,true,true,false,2,true,true,true,4]");
+ }
+
+ class MyCircularDeque {
+ private int[] elements;
+ private int rear, front;
+ private int capacity;
+
+ public MyCircularDeque(int k) {
+ capacity = k + 1;
+ rear = front = 0;
+ elements = new int[k + 1];
+ }
+
+ public boolean insertFront(int value) {
+ if (isFull()) {
+ return false;
+ }
+ front = (front - 1 + capacity) % capacity;
+ elements[front] = value;
+ return true;
+ }
+
+ public boolean insertLast(int value) {
+ if (isFull()) {
+ return false;
+ }
+ elements[rear] = value;
+ rear = (rear + 1) % capacity;
+ return true;
+ }
+
+ public boolean deleteFront() {
+ if (isEmpty()) {
+ return false;
+ }
+ front = (front + 1) % capacity;
+ return true;
+ }
+
+ public boolean deleteLast() {
+ if (isEmpty()) {
+ return false;
+ }
+ rear = (rear - 1 + capacity) % capacity;
+ return true;
+ }
+
+ public int getFront() {
+ if (isEmpty()) {
+ return -1;
+ }
+ return elements[front];
+ }
+
+ public int getRear() {
+ if (isEmpty()) {
+ return -1;
+ }
+ return elements[(rear - 1 + capacity) % capacity];
+ }
+
+ public boolean isEmpty() {
+ return rear == front;
+ }
+
+ public boolean isFull() {
+ return (rear + 1) % capacity == front;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase08.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase08.java
new file mode 100644
index 0000000..e0143e5
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase08.java
@@ -0,0 +1,48 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet4_TestCase08 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"MagicDictionary\", \"buildDict\", \"search\", \"search\", \"search\", " +
+ "\"search\"] [[], [[\"hello\", \"leetcode\"]], [\"hello\"], [\"hhllo\"], [\"hell\"], [\"leetcoded\"]]");
+ expectString("[null,null,false,true,false,false]");
+ }
+
+ class MagicDictionary {
+ private String[] words;
+
+ public MagicDictionary() {
+
+ }
+
+ public void buildDict(String[] dictionary) {
+ words = dictionary;
+ }
+
+ public boolean search(String searchWord) {
+ for (String word : words) {
+ if (word.length() != searchWord.length()) {
+ continue;
+ }
+
+ int diff = 0;
+ for (int i = 0; i < word.length(); ++i) {
+ if (word.charAt(i) != searchWord.charAt(i)) {
+ ++diff;
+ if (diff > 1) {
+ break;
+ }
+ }
+ }
+ if (diff == 1) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase09.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase09.java
new file mode 100644
index 0000000..ff8757a
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase09.java
@@ -0,0 +1,39 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class TestSet4_TestCase09 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"MapSum\", \"insert\", \"sum\", \"insert\", \"sum\"] [[], [\"apple\", " +
+ "3], [\"ap\"], [\"app\", 2], [\"ap\"]]");
+ expectString("[null,null,3,null,5]");
+ }
+
+ class MapSum {
+ Map map;
+
+ public MapSum() {
+ map = new HashMap<>();
+ }
+
+ public void insert(String key, int val) {
+ map.put(key, val);
+ }
+
+ public int sum(String prefix) {
+ int res = 0;
+ for (String s : map.keySet()) {
+ if (s.startsWith(prefix)) {
+ res += map.get(s);
+ }
+ }
+ return res;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase10.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase10.java
new file mode 100644
index 0000000..75ab01d
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase10.java
@@ -0,0 +1,37 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.PriorityQueue;
+
+public class TestSet4_TestCase10 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"KthLargest\", \"add\", \"add\", \"add\", \"add\", \"add\"] " +
+ "[[3, [4, 5, 8, 2]], [3], [5], [10], [9], [4]]");
+ expectString("[null,4,5,5,8,8]");
+ }
+
+ class KthLargest {
+ PriorityQueue pq;
+ int k;
+
+ public KthLargest(int k, int[] nums) {
+ this.k = k;
+ pq = new PriorityQueue();
+ for (int x : nums) {
+ add(x);
+ }
+ }
+
+ public int add(int val) {
+ pq.offer(val);
+ if (pq.size() > k) {
+ pq.poll();
+ }
+ return pq.peek();
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase11.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase11.java
new file mode 100644
index 0000000..f3c6325
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase11.java
@@ -0,0 +1,59 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet4_TestCase11 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"Trie\", \"insert\", \"search\", \"search\", \"startsWith\", \"insert\"," +
+ " \"search\"] [[], [\"apple\"], [\"apple\"], [\"app\"], [\"app\"], [\"app\"], [\"app\"]]");
+ expectString("[null,null,true,false,true,null,true]");
+ }
+
+ class Trie {
+ private Trie[] children;
+ private boolean isEnd;
+
+ public Trie() {
+ children = new Trie[26];
+ isEnd = false;
+ }
+
+ public void insert(String word) {
+ Trie node = this;
+ for (int i = 0; i < word.length(); i++) {
+ char ch = word.charAt(i);
+ int index = ch - 'a';
+ if (node.children[index] == null) {
+ node.children[index] = new Trie();
+ }
+ node = node.children[index];
+ }
+ node.isEnd = true;
+ }
+
+ public boolean search(String word) {
+ Trie node = searchPrefix(word);
+ return node != null && node.isEnd;
+ }
+
+ public boolean startsWith(String prefix) {
+ return searchPrefix(prefix) != null;
+ }
+
+ private Trie searchPrefix(String prefix) {
+ Trie node = this;
+ for (int i = 0; i < prefix.length(); i++) {
+ char ch = prefix.charAt(i);
+ int index = ch - 'a';
+ if (node.children[index] == null) {
+ return null;
+ }
+ node = node.children[index];
+ }
+ return node;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase12.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase12.java
new file mode 100644
index 0000000..7733a97
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase12.java
@@ -0,0 +1,54 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet4_TestCase12 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"Allocator\", \"allocate\", \"allocate\", \"allocate\", \"freeMemory\", " +
+ "\"allocate\", \"allocate\", \"allocate\", \"freeMemory\", \"allocate\", \"freeMemory\"] [[10], [1, " +
+ "1], [1, 2], [1, 3], [2], [3, 4], [1, 1], [1, 1], [1], [10, 2], [7]]");
+ expectString("[null,0,1,2,1,3,1,6,3,-1,0]");
+ }
+
+ class Allocator {
+ private int n;
+ private int[] memory;
+
+ public Allocator(int n) {
+ this.n = n;
+ this.memory = new int[n];
+ }
+
+ public int allocate(int size, int mID) {
+ int count = 0;
+ for (int i = 0; i < n; ++i) {
+ if (memory[i] != 0) {
+ count = 0;
+ } else {
+ ++count;
+ if (count == size) {
+ for (int j = i - count + 1; j <= i; ++j) {
+ memory[j] = mID;
+ }
+ return i - count + 1;
+ }
+ }
+ }
+ return -1;
+ }
+
+ public int freeMemory(int mID) {
+ int count = 0;
+ for (int i = 0; i < n; ++i) {
+ if (memory[i] == mID) {
+ ++count;
+ memory[i] = 0;
+ }
+ }
+ return count;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase13.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase13.java
new file mode 100644
index 0000000..e17f628
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase13.java
@@ -0,0 +1,101 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+public class TestSet4_TestCase13 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"TextEditor\", \"addText\", \"deleteText\", \"addText\", " +
+ "\"cursorRight\", \"cursorLeft\", \"deleteText\", \"cursorLeft\", \"cursorRight\"] " +
+ "[[], [\"leetcode\"], [4], [\"practice\"], [3], [8], [10], [2], [6]]");
+ expectString("[null,null,4,null,\"etpractice\",\"leet\",4,\"\",\"practi\"]");
+ }
+
+ class TextEditor {
+
+ private Node cursor;
+
+ public TextEditor() {
+ cursor = new Node('\0');
+ }
+
+ public void addText(String text) {
+ for (char c : text.toCharArray()) {
+ cursor.insert(c);
+ }
+ }
+
+ public int deleteText(int k) {
+ int count = 0;
+ while (k > 0 && cursor.prev != null) {
+ cursor.remove();
+ k--;
+ count++;
+ }
+ return count;
+ }
+
+ public String cursorLeft(int k) {
+ while (k > 0 && cursor.prev != null) {
+ cursor = cursor.prev;
+ k--;
+ }
+ Node head = cursor;
+ for (int i = 0; i < 10 && head.prev != null; i++) {
+ head = head.prev;
+ }
+ return head.range(cursor);
+ }
+
+ public String cursorRight(int k) {
+ while (k > 0 && cursor.next != null) {
+ cursor = cursor.next;
+ k--;
+ }
+ Node head = cursor;
+ for (int i = 0; i < 10 && head.prev != null; i++) {
+ head = head.prev;
+ }
+ return head.range(cursor);
+ }
+
+ class Node {
+ char val;
+ Node prev, next;
+
+ Node(char val) {
+ this.val = val;
+ }
+
+ void insert(char val) {
+ Node node = new Node(val);
+ node.next = this;
+ node.prev = this.prev;
+ if (this.prev != null) {
+ this.prev.next = node;
+ }
+ this.prev = node;
+ }
+
+ void remove() {
+ Node node = this.prev;
+ this.prev = node.prev;
+ if (node.prev != null) {
+ node.prev.next = this;
+ }
+ }
+
+ String range(Node end) {
+ StringBuilder sb = new StringBuilder();
+ Node node = this;
+ while (node != end) {
+ sb.append(node.val);
+ node = node.next;
+ }
+ return sb.toString();
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase14.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase14.java
new file mode 100644
index 0000000..dfc5197
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase14.java
@@ -0,0 +1,58 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestSet4_TestCase14 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"SnapshotArray\",\"set\",\"snap\",\"set\",\"get\"]" +
+ " [[3],[0,5],[],[0,6],[0,0]]");
+ expectString("[null,null,0,null,5]");
+ }
+
+ @SuppressWarnings("unchecked")
+ class SnapshotArray {
+ private int snap_cnt;
+ private List[] data;
+
+ public SnapshotArray(int length) {
+ snap_cnt = 0;
+ data = new List[length];
+ for (int i = 0; i < length; i++) {
+ data[i] = new ArrayList();
+ }
+ }
+
+ public void set(int index, int val) {
+ data[index].add(new int[]{snap_cnt, val});
+ }
+
+ public int snap() {
+ return snap_cnt++;
+ }
+
+ public int get(int index, int snap_id) {
+ int x = binarySearch(index, snap_id);
+ return x == 0 ? 0 : data[index].get(x - 1)[1];
+ }
+
+ private int binarySearch(int index, int snap_id) {
+ int low = 0, high = data[index].size();
+ while (low < high) {
+ int mid = low + (high - low) / 2;
+ int[] pair = data[index].get(mid);
+ if (pair[0] > snap_id + 1 || (pair[0] == snap_id + 1 && pair[1] >= 0)) {
+ high = mid;
+ } else {
+ low = mid + 1;
+ }
+ }
+ return low;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase15.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase15.java
new file mode 100644
index 0000000..b70d95d
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase15.java
@@ -0,0 +1,103 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.LinkedList;
+import java.util.Queue;
+
+public class TestSet4_TestCase15 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"StreamChecker\", \"query\", \"query\", \"query\", \"query\", \"query\"," +
+ " \"query\", \"query\", \"query\", \"query\", \"query\", \"query\", \"query\"] " +
+ "[[[\"cd\", \"f\", \"kl\"]], [\"a\"], [\"b\"], [\"c\"], [\"d\"], [\"e\"], [\"f\"], [\"g\"], [\"h\"], " +
+ "[\"i\"], [\"j\"], [\"k\"], [\"l\"]]");
+ expectString("[null,false,false,false,true,false,true,false,false,false,false,false,true]");
+ }
+
+ class StreamChecker {
+
+ class TrieNode {
+ TrieNode[] children;
+ boolean isEnd;
+ TrieNode fail;
+
+ public TrieNode() {
+ children = new TrieNode[26];
+ }
+
+ public TrieNode getChild(int index) {
+ return children[index];
+ }
+
+ public void setChild(int index, TrieNode node) {
+ children[index] = node;
+ }
+
+ public boolean getIsEnd() {
+ return isEnd;
+ }
+
+ public void setIsEnd(boolean b) {
+ isEnd = b;
+ }
+
+ public TrieNode getFail() {
+ return fail;
+ }
+
+ public void setFail(TrieNode node) {
+ fail = node;
+ }
+ }
+
+ TrieNode root;
+ TrieNode temp;
+
+ public StreamChecker(String[] words) {
+ root = new TrieNode();
+ for (String word : words) {
+ TrieNode cur = root;
+ for (int i = 0; i < word.length(); i++) {
+ int index = word.charAt(i) - 'a';
+ if (cur.getChild(index) == null) {
+ cur.setChild(index, new TrieNode());
+ }
+ cur = cur.getChild(index);
+ }
+ cur.setIsEnd(true);
+ }
+ root.setFail(root);
+ Queue q = new LinkedList<>();
+ for (int i = 0; i < 26; i++) {
+ if (root.getChild(i) != null) {
+ root.getChild(i).setFail(root);
+ q.add(root.getChild(i));
+ } else {
+ root.setChild(i, root);
+ }
+ }
+ while (!q.isEmpty()) {
+ TrieNode node = q.poll();
+ node.setIsEnd(node.getIsEnd() || node.getFail().getIsEnd());
+ for (int i = 0; i < 26; i++) {
+ if (node.getChild(i) != null) {
+ node.getChild(i).setFail(node.getFail().getChild(i));
+ q.offer(node.getChild(i));
+ } else {
+ node.setChild(i, node.getFail().getChild(i));
+ }
+ }
+ }
+
+ temp = root;
+ }
+
+ public boolean query(char letter) {
+ temp = temp.getChild(letter - 'a');
+ return temp.getIsEnd();
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase16.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase16.java
new file mode 100644
index 0000000..a14b587
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase16.java
@@ -0,0 +1,76 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.*;
+
+public class TestSet4_TestCase16 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"MajorityChecker\", \"query\", \"query\", \"query\"] " +
+ "[[[1, 1, 2, 2, 1, 1]], [0, 5, 4], [0, 3, 3], [2, 3, 2]]");
+ expectString("[null,1,-1,2]");
+ }
+
+ class MajorityChecker {
+ public static final int K = 20;
+ private int[] arr;
+ private Map> loc;
+ private Random random;
+
+ public MajorityChecker(int[] arr) {
+ this.arr = arr;
+ this.loc = new HashMap>();
+ for (int i = 0; i < arr.length; ++i) {
+ loc.putIfAbsent(arr[i], new ArrayList());
+ loc.get(arr[i]).add(i);
+ }
+ this.random = new Random();
+ }
+
+ public int query(int left, int right, int threshold) {
+ int length = right - left + 1;
+
+ for (int i = 0; i < K; ++i) {
+ int x = arr[left + random.nextInt(length)];
+ List pos = loc.get(x);
+ int occ = searchEnd(pos, right) - searchStart(pos, left);
+ if (occ >= threshold) {
+ return x;
+ } else if (occ * 2 >= length) {
+ return -1;
+ }
+ }
+
+ return -1;
+ }
+
+ private int searchStart(List pos, int target) {
+ int low = 0, high = pos.size();
+ while (low < high) {
+ int mid = low + (high - low) / 2;
+ if (pos.get(mid) >= target) {
+ high = mid;
+ } else {
+ low = mid + 1;
+ }
+ }
+ return low;
+ }
+
+ private int searchEnd(List pos, int target) {
+ int low = 0, high = pos.size();
+ while (low < high) {
+ int mid = low + (high - low) / 2;
+ if (pos.get(mid) > target) {
+ high = mid;
+ } else {
+ low = mid + 1;
+ }
+ }
+ return low;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase17.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase17.java
new file mode 100644
index 0000000..1318e4b
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase17.java
@@ -0,0 +1,114 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class TestSet4_TestCase17 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"AllOne\", \"inc\", \"inc\", \"getMaxKey\", \"getMinKey\", \"inc\", " +
+ "\"getMaxKey\", \"getMinKey\"] " +
+ "[[], [\"hello\"], [\"hello\"], [], [], [\"leet\"], [], []]");
+ expectString("[null,null,null,\"hello\",\"hello\",null,\"hello\",\"leet\"]");
+ }
+
+ class AllOne {
+ Node root;
+ Map nodes;
+
+ public AllOne() {
+ root = new Node();
+ root.prev = root;
+ root.next = root;
+ nodes = new HashMap();
+ }
+
+ public void inc(String key) {
+ if (nodes.containsKey(key)) {
+ Node cur = nodes.get(key);
+ Node nxt = cur.next;
+ if (nxt == root || nxt.count > cur.count + 1) {
+ nodes.put(key, cur.insert(new Node(key, cur.count + 1)));
+ } else {
+ nxt.keys.add(key);
+ nodes.put(key, nxt);
+ }
+ cur.keys.remove(key);
+ if (cur.keys.isEmpty()) {
+ cur.remove();
+ }
+ } else {
+ if (root.next == root || root.next.count > 1) {
+ nodes.put(key, root.insert(new Node(key, 1)));
+ } else {
+ root.next.keys.add(key);
+ nodes.put(key, root.next);
+ }
+ }
+ }
+
+ public void dec(String key) {
+ Node cur = nodes.get(key);
+ if (cur.count == 1) {
+ nodes.remove(key);
+ } else {
+ Node pre = cur.prev;
+ if (pre == root || pre.count < cur.count - 1) {
+ nodes.put(key, cur.prev.insert(new Node(key, cur.count - 1)));
+ } else {
+ pre.keys.add(key);
+ nodes.put(key, pre);
+ }
+ }
+ cur.keys.remove(key);
+ if (cur.keys.isEmpty()) {
+ cur.remove();
+ }
+ }
+
+ public String getMaxKey() {
+ return root.prev != null ? root.prev.keys.iterator().next() : "";
+ }
+
+ public String getMinKey() {
+ return root.next != null ? root.next.keys.iterator().next() : "";
+ }
+
+ class Node {
+ Node prev;
+ Node next;
+ Set keys;
+ int count;
+
+ public Node() {
+ this("", 0);
+ }
+
+ public Node(String key, int count) {
+ this.count = count;
+ keys = new HashSet();
+ keys.add(key);
+ }
+
+ public Node insert(Node node) {
+ node.prev = this;
+ node.next = this.next;
+ node.prev.next = node;
+ node.next.prev = node;
+ return node;
+ }
+
+ public void remove() {
+ this.prev.next = this.next;
+ this.next.prev = this.prev;
+ }
+ }
+ }
+
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase18.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase18.java
new file mode 100644
index 0000000..53172cc
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase18.java
@@ -0,0 +1,36 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestSet4_TestCase18 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"MyCalendar\", \"book\", \"book\", \"book\"] " +
+ "[[], [10, 20], [15, 25], [20, 30]]");
+ expectString("[null,true,false,true]");
+ }
+
+ class MyCalendar {
+ List booked;
+
+ public MyCalendar() {
+ booked = new ArrayList();
+ }
+
+ public boolean book(int start, int end) {
+ for (int[] arr : booked) {
+ int l = arr[0], r = arr[1];
+ if (l < end && start < r) {
+ return false;
+ }
+ }
+ booked.add(new int[]{start, end});
+ return true;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase19.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase19.java
new file mode 100644
index 0000000..917399b
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase19.java
@@ -0,0 +1,54 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TestSet4_TestCase19 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"TopVotedCandidate\", \"q\", \"q\", \"q\", \"q\", \"q\", \"q\"] " +
+ "[[[0, 1, 1, 0, 0, 1, 0], [0, 5, 10, 15, 20, 25, 30]], [3], [12], [25], [15], [24], [8]]");
+ expectString("[null,0,1,1,0,0,1]");
+ }
+
+ class TopVotedCandidate {
+ List tops;
+ Map voteCounts;
+ int[] times;
+
+ public TopVotedCandidate(int[] persons, int[] times) {
+ tops = new ArrayList();
+ voteCounts = new HashMap();
+ voteCounts.put(-1, -1);
+ int top = -1;
+ for (int i = 0; i < persons.length; ++i) {
+ int p = persons[i];
+ voteCounts.put(p, voteCounts.getOrDefault(p, 0) + 1);
+ if (voteCounts.get(p) >= voteCounts.get(top)) {
+ top = p;
+ }
+ tops.add(top);
+ }
+ this.times = times;
+ }
+
+ public int q(int t) {
+ int l = 0, r = times.length - 1;
+ while (l < r) {
+ int m = l + (r - l + 1) / 2;
+ if (times[m] <= t) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+ return tops.get(l);
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase20.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase20.java
new file mode 100644
index 0000000..7b4e772
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase20.java
@@ -0,0 +1,49 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestSet4_TestCase20 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[\"BrowserHistory\",\"visit\",\"visit\",\"visit\",\"back\",\"back\"," +
+ "\"forward\",\"visit\",\"forward\",\"back\",\"back\"] " +
+ "[[\"leetcode.com\"],[\"google.com\"],[\"facebook.com\"],[\"youtube.com\"],[1],[1],[1],[\"linkedin" +
+ ".com\"],[2],[2],[7]]");
+ expectString("[null,null,null,null,\"facebook.com\",\"google.com\",\"facebook.com\",null,\"linkedin.com\"," +
+ "\"google.com\",\"leetcode.com\"]");
+ }
+
+ class BrowserHistory {
+ private List urls;
+ private int currIndex;
+
+ public BrowserHistory(String homepage) {
+ this.urls = new ArrayList<>();
+ this.urls.add(homepage);
+ this.currIndex = 0;
+ }
+
+ public void visit(String url) {
+ while (urls.size() > currIndex + 1) {
+ urls.remove(urls.size() - 1);
+ }
+ urls.add(url);
+ this.currIndex++;
+ }
+
+ public String back(int steps) {
+ currIndex = Math.max(currIndex - steps, 0);
+ return urls.get(currIndex);
+ }
+
+ public String forward(int steps) {
+ currIndex = Math.min(currIndex + steps, urls.size() - 1);
+ return urls.get(currIndex);
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase01.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase01.java
new file mode 100644
index 0000000..19552d1
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase01.java
@@ -0,0 +1,34 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestSet5_TestCase01 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,null,2,3]", "[]", "[1]");
+ expectString("[1,3,2]", "[]", "[1]");
+ }
+
+ class Solution {
+ public List inorderTraversal(TreeNode root) {
+ List res = new ArrayList();
+ inorder(root, res);
+ return res;
+ }
+
+ public void inorder(TreeNode root, List res) {
+ if (root == null) {
+ return;
+ }
+ inorder(root.left, res);
+ res.add(root.val);
+ inorder(root.right, res);
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase02.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase02.java
new file mode 100644
index 0000000..b9f5b53
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase02.java
@@ -0,0 +1,48 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class TestSet5_TestCase02 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[3,9,20,15,7] [9,3,15,20,7]", "[-1] [-1]");
+ expectString("[3,9,20,null,null,15,7]", "[-1]");
+ }
+
+ class Solution {
+ private Map indexMap;
+
+ public TreeNode myBuildTree(int[] preorder, int[] inorder, int preorder_left, int preorder_right,
+ int inorder_left, int inorder_right) {
+ if (preorder_left > preorder_right) {
+ return null;
+ }
+
+ int preorder_root = preorder_left;
+ int inorder_root = indexMap.get(preorder[preorder_root]);
+
+ TreeNode root = new TreeNode(preorder[preorder_root]);
+ int size_left_subtree = inorder_root - inorder_left;
+ root.left = myBuildTree(preorder, inorder, preorder_left + 1, preorder_left + size_left_subtree,
+ inorder_left, inorder_root - 1);
+ root.right = myBuildTree(preorder, inorder, preorder_left + size_left_subtree + 1, preorder_right,
+ inorder_root + 1, inorder_right);
+ return root;
+ }
+
+ public TreeNode buildTree(int[] preorder, int[] inorder) {
+ int n = preorder.length;
+ indexMap = new HashMap();
+ for (int i = 0; i < n; i++) {
+ indexMap.put(inorder[i], i);
+ }
+ return myBuildTree(preorder, inorder, 0, n - 1, 0, n - 1);
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase03.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase03.java
new file mode 100644
index 0000000..8118777
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase03.java
@@ -0,0 +1,43 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+public class TestSet5_TestCase03 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[-10,-3,0,5,9]", "[]");
+ expectString("[0,-3,9,-10,null,5]", "[]");
+ }
+
+ class Solution {
+ public TreeNode sortedListToBST(ListNode head) {
+ return buildTree(head, null);
+ }
+
+ public TreeNode buildTree(ListNode left, ListNode right) {
+ if (left == right) {
+ return null;
+ }
+ ListNode mid = getMedian(left, right);
+ TreeNode root = new TreeNode(mid.val);
+ root.left = buildTree(left, mid);
+ root.right = buildTree(mid.next, right);
+ return root;
+ }
+
+ public ListNode getMedian(ListNode left, ListNode right) {
+ ListNode fast = left;
+ ListNode slow = left;
+ while (fast != right && fast.next != right) {
+ fast = fast.next;
+ fast = fast.next;
+ slow = slow.next;
+ }
+ return slow;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase04.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase04.java
new file mode 100644
index 0000000..53da218
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase04.java
@@ -0,0 +1,49 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestSet5_TestCase04 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,null,2,null,3,null,4,null,null]", "[2,1,3]");
+ expectString("[2,1,3,null,null,null,4]", "[2,1,3]");
+ }
+
+ class Solution {
+ List inorderSeq;
+
+ public TreeNode balanceBST(TreeNode root) {
+ inorderSeq = new ArrayList<>();
+ getInorder(root);
+ return build(0, inorderSeq.size() - 1);
+ }
+
+ private void getInorder(TreeNode o) {
+ if (o.left != null) {
+ getInorder(o.left);
+ }
+ inorderSeq.add(o.val);
+ if (o.right != null) {
+ getInorder(o.right);
+ }
+ }
+
+ private TreeNode build(int l, int r) {
+ int mid = (l + r) >> 1;
+ TreeNode o = new TreeNode(inorderSeq.get(mid));
+ if (l <= mid - 1) {
+ o.left = build(l, mid - 1);
+ }
+ if (mid + 1 <= r) {
+ o.right = build(mid + 1, r);
+ }
+ return o;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase05.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase05.java
new file mode 100644
index 0000000..73c6390
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase05.java
@@ -0,0 +1,50 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+import java.util.ArrayDeque;
+import java.util.Queue;
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestSet5_TestCase05 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[2,3,5,8,13,21,34]", "[0,1,2,0,0,0,0,1,1,1,1,2,2,2,2]");
+ expectString("[2,5,3,8,13,21,34]", "[0,2,1,0,0,0,0,2,2,2,2,1,1,1,1]");
+ }
+
+ class Solution {
+ public TreeNode reverseOddLevels(TreeNode root) {
+ Queue queue = new ArrayDeque();
+ queue.offer(root);
+ boolean isOdd = false;
+ while (!queue.isEmpty()) {
+ int sz = queue.size();
+ List arr = new ArrayList();
+ for (int i = 0; i < sz; i++) {
+ TreeNode node = queue.poll();
+ if (isOdd) {
+ arr.add(node);
+ }
+ if (node.left != null) {
+ queue.offer(node.left);
+ queue.offer(node.right);
+ }
+ }
+ if (isOdd) {
+ for (int l = 0, r = sz - 1; l < r; l++, r--) {
+ int temp = arr.get(l).val;
+ arr.get(l).val = arr.get(r).val;
+ arr.get(r).val = temp;
+ }
+ }
+ isOdd ^= true;
+ }
+ return root;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase06.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase06.java
new file mode 100644
index 0000000..8c5d7f8
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase06.java
@@ -0,0 +1,69 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+public class TestSet5_TestCase06 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[5,1,2,3,null,6,4] 3 6", "[2,1] 2 1");
+ expectString("\"UURL\"", "\"L\"");
+ }
+
+ class Solution {
+ StringBuilder res, start, dest;
+
+ public String getDirections(TreeNode root, int startValue, int destValue) {
+ res = new StringBuilder();
+ start = new StringBuilder();
+ dest = new StringBuilder();
+ TreeNode ancestor = findRoot(root, startValue, destValue);
+ dfsStart(ancestor, startValue);
+ dfsDest(ancestor, destValue);
+ return res.toString();
+ }
+
+ private void dfsStart(TreeNode root, int startValue) {
+ if (root == null) {
+ return;
+ }
+ if (root.val == startValue) {
+ res.append(start);
+ return;
+ }
+ start.append("U");
+ dfsStart(root.left, startValue);
+ start.deleteCharAt(start.length() - 1);
+ start.append("U");
+ dfsStart(root.right, startValue);
+ start.deleteCharAt(start.length() - 1);
+ }
+
+ private void dfsDest(TreeNode root, int destValue) {
+ if (root == null) {
+ return;
+ }
+ if (root.val == destValue) {
+ res.append(dest);
+ return;
+ }
+ dest.append("L");
+ dfsDest(root.left, destValue);
+ dest.deleteCharAt(dest.length() - 1);
+ dest.append("R");
+ dfsDest(root.right, destValue);
+ dest.deleteCharAt(dest.length() - 1);
+ }
+
+ private TreeNode findRoot(TreeNode root, int startValue, int destValue) {
+ if (root == null || root.val == startValue || root.val == destValue) return root;
+ TreeNode left = findRoot(root.left, startValue, destValue);
+ TreeNode right = findRoot(root.right, startValue, destValue);
+ if (left == null) return right;
+ if (right == null) return left;
+ return root;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase07.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase07.java
new file mode 100644
index 0000000..3a1e1de
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase07.java
@@ -0,0 +1,36 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+public class TestSet5_TestCase07 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[3,2,1,6,0,5]", "[3,2,1]");
+ expectString("[6,3,5,null,2,0,null,null,1]", "[3,null,2,null,1]");
+ }
+
+ class Solution {
+ public TreeNode constructMaximumBinaryTree(int[] nums) {
+ return construct(nums, 0, nums.length - 1);
+ }
+
+ public TreeNode construct(int[] nums, int left, int right) {
+ if (left > right) {
+ return null;
+ }
+ int best = left;
+ for (int i = left + 1; i <= right; ++i) {
+ if (nums[i] > nums[best]) {
+ best = i;
+ }
+ }
+ TreeNode node = new TreeNode(nums[best]);
+ node.left = construct(nums, left, best - 1);
+ node.right = construct(nums, best + 1, right);
+ return node;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase08.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase08.java
new file mode 100644
index 0000000..6d58bcc
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase08.java
@@ -0,0 +1,36 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+
+public class TestSet5_TestCase08 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[3,1,4,null,2] 1", "[5,3,6,2,4,null,null,1] 3");
+ expectString("1", "3");
+ }
+
+ class Solution {
+ public int kthSmallest(TreeNode root, int k) {
+ Deque stack = new ArrayDeque();
+ while (root != null || !stack.isEmpty()) {
+ while (root != null) {
+ stack.push(root);
+ root = root.left;
+ }
+ root = stack.pop();
+ --k;
+ if (k == 0) {
+ break;
+ }
+ root = root.right;
+ }
+ return root.val;
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase09.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase09.java
new file mode 100644
index 0000000..0826bd4
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase09.java
@@ -0,0 +1,53 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestSet5_TestCase09 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[2,1,4] [1,0,3]", "[1,null,8] [8,1]");
+ expectString("[0,1,1,2,3,4]", "[1,1,8,8]");
+ }
+
+ class Solution {
+ public List getAllElements(TreeNode root1, TreeNode root2) {
+ List nums1 = new ArrayList();
+ List nums2 = new ArrayList();
+ inorder(root1, nums1);
+ inorder(root2, nums2);
+
+ List merged = new ArrayList();
+ int p1 = 0, p2 = 0;
+ while (true) {
+ if (p1 == nums1.size()) {
+ merged.addAll(nums2.subList(p2, nums2.size()));
+ break;
+ }
+ if (p2 == nums2.size()) {
+ merged.addAll(nums1.subList(p1, nums1.size()));
+ break;
+ }
+ if (nums1.get(p1) < nums2.get(p2)) {
+ merged.add(nums1.get(p1++));
+ } else {
+ merged.add(nums2.get(p2++));
+ }
+ }
+ return merged;
+ }
+
+ private void inorder(TreeNode node, List res) {
+ if (node != null) {
+ inorder(node.left, res);
+ res.add(node.val);
+ inorder(node.right, res);
+ }
+ }
+ }
+}
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase10.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase10.java
new file mode 100644
index 0000000..08ca4cc
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase10.java
@@ -0,0 +1,31 @@
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+
+import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
+import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
+import org.junit.Before;
+
+public class TestSet5_TestCase10 extends UnitTestDriver {
+
+ @Before
+ public void onBefore() {
+ registerDriverWithAutoCustomStdIn("[1,0,2] 1 2", "[3,0,4,null,2,null,null,1] 1 3");
+ expectString("[1,null,2]", "[3,2,null,1]");
+ }
+
+ class Solution {
+ public TreeNode trimBST(TreeNode root, int low, int high) {
+ if (root == null) {
+ return null;
+ }
+ if (root.val < low) {
+ return trimBST(root.right, low, high);
+ } else if (root.val > high) {
+ return trimBST(root.left, low, high);
+ } else {
+ root.left = trimBST(root.left, low, high);
+ root.right = trimBST(root.right, low, high);
+ return root;
+ }
+ }
+ }
+}
From 2a12ca18b645b64be76df98f337bf9598717f28f Mon Sep 17 00:00:00 2001
From: Jidcoo <1337753396@qq.com>
Date: Mon, 3 Mar 2025 23:16:56 +0800
Subject: [PATCH 03/32] add docs.
---
.../opto/lcdb/enhancer/UnitTestDriver.java | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/UnitTestDriver.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/UnitTestDriver.java
index 616cd11..3046033 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/UnitTestDriver.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/UnitTestDriver.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer;
import io.github.jidcoo.opto.lcdb.enhancer.base.OutputConsumer;
@@ -20,6 +36,16 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+/**
+ *
UnitTestDriver is a driver that run a junit-test on this project.
+ *
All junit-test classes must extend from this class!!!
+ *
+ * @author Jidcoo
+ * @see UnitTestDriver#registerDriver()
+ * @see UnitTestDriver#registerDriverWithAutoCustomStdIn(String...)
+ * @see UnitTestDriver#expectString(String...)
+ * @see UnitTestDriver#ignoreTestResult()
+ */
@RunWith(JUnit4.class)
public abstract class UnitTestDriver extends LeetcodeJavaDebugEnhancer {
@@ -79,12 +105,20 @@ public OutputConsumer getOutputConsumer() {
return new MultipleOutputConsumer(outputConsumers);
}
+ /**
+ * Ignore the test result.
+ */
protected final void ignoreTestResult() {
if (!__IS__IGNORED__OUTPUT__) {
__IS__IGNORED__OUTPUT__ = true;
}
}
+ /**
+ * Assert that the test result with expected result.
+ *
+ * @param expectedResult the expected results.
+ */
protected final void expectString(String... expectedResult) {
if (__IS__IGNORED__OUTPUT__) {
return;
@@ -99,6 +133,13 @@ protected final void expectString(String... expectedResult) {
__TEST_EXPECTED_RESULT__ = buf.toString();
}
+ /**
+ * Register driver to cur junit-test instance.
+ *
+ * @apiNote Before running the test, one of {@link UnitTestDriver#registerDriver()}
+ * or {@link UnitTestDriver#registerDriverWithAutoCustomStdIn(String...)}
+ * must be called to register the driver to current junit-test instance.
+ */
protected final void registerDriver() {
if (!__IS__REGISTERED__) {
System.setProperty("sun.java.command", this.getClass().getName());
@@ -106,6 +147,14 @@ protected final void registerDriver() {
}
}
+ /**
+ * Register driver to cur junit-test instance with auto custom
+ * system standard input.
+ *
+ * @apiNote Before running the test, one of {@link UnitTestDriver#registerDriver()}
+ * or {@link UnitTestDriver#registerDriverWithAutoCustomStdIn(String...)}
+ * must be called to register the driver to current junit-test instance.
+ */
protected final void registerDriverWithAutoCustomStdIn(String... stdIn) {
Assert.assertNotNull(stdIn);
if (stdIn.length == 0) {
From 264077331b2fa9726c29ef36f341fea77ec4505d Mon Sep 17 00:00:00 2001
From: Jidcoo <1337753396@qq.com>
Date: Wed, 5 Mar 2025 23:25:50 +0800
Subject: [PATCH 04/32] Add docs for tests.
---
.../testset1/TestSet1_TestCase01.java | 22 +++++++++++++++++
.../testset1/TestSet1_TestCase02.java | 22 +++++++++++++++++
.../testset1/TestSet1_TestCase03.java | 22 +++++++++++++++++
.../testset1/TestSet1_TestCase04.java | 22 +++++++++++++++++
.../testset1/TestSet1_TestCase05.java | 22 +++++++++++++++++
.../testset1/TestSet1_TestCase06.java | 22 +++++++++++++++++
.../testset1/TestSet1_TestCase07.java | 22 +++++++++++++++++
.../testset1/TestSet1_TestCase08.java | 22 +++++++++++++++++
.../testset1/TestSet1_TestCase09.java | 22 +++++++++++++++++
.../testset1/TestSet1_TestCase10.java | 22 +++++++++++++++++
.../lcdb/enhancer/testset1/package-info.java | 6 +++++
.../testset2/TestSet2_TestCase01.java | 22 +++++++++++++++++
.../testset2/TestSet2_TestCase02.java | 22 +++++++++++++++++
.../testset2/TestSet2_TestCase03.java | 22 +++++++++++++++++
.../testset2/TestSet2_TestCase04.java | 22 +++++++++++++++++
.../testset2/TestSet2_TestCase05.java | 22 +++++++++++++++++
.../testset2/TestSet2_TestCase06.java | 22 +++++++++++++++++
.../testset2/TestSet2_TestCase07.java | 22 +++++++++++++++++
.../testset2/TestSet2_TestCase08.java | 22 +++++++++++++++++
.../testset2/TestSet2_TestCase09.java | 22 +++++++++++++++++
.../testset2/TestSet2_TestCase10.java | 22 +++++++++++++++++
.../lcdb/enhancer/testset2/package-info.java | 6 +++++
.../testset3/TestSet3_TestCase01.java | 23 ++++++++++++++++++
.../testset3/TestSet3_TestCase02.java | 23 ++++++++++++++++++
.../testset3/TestSet3_TestCase03.java | 23 ++++++++++++++++++
.../testset3/TestSet3_TestCase04.java | 23 ++++++++++++++++++
.../testset3/TestSet3_TestCase05.java | 23 ++++++++++++++++++
.../testset3/TestSet3_TestCase06.java | 23 ++++++++++++++++++
.../testset3/TestSet3_TestCase07.java | 23 ++++++++++++++++++
.../testset3/TestSet3_TestCase08.java | 23 ++++++++++++++++++
.../testset3/TestSet3_TestCase09.java | 23 ++++++++++++++++++
.../testset3/TestSet3_TestCase10.java | 24 ++++++++++++++++++-
.../lcdb/enhancer/testset3/package-info.java | 7 ++++++
.../testset4/TestSet4_TestCase01.java | 24 +++++++++++++++++++
.../testset4/TestSet4_TestCase02.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase03.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase04.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase05.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase06.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase07.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase08.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase09.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase10.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase11.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase12.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase13.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase14.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase15.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase16.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase17.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase18.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase19.java | 23 ++++++++++++++++++
.../testset4/TestSet4_TestCase20.java | 23 ++++++++++++++++++
.../lcdb/enhancer/testset4/package-info.java | 7 ++++++
.../testset5/TestSet5_TestCase01.java | 23 ++++++++++++++++++
.../testset5/TestSet5_TestCase02.java | 23 ++++++++++++++++++
.../testset5/TestSet5_TestCase03.java | 23 ++++++++++++++++++
.../testset5/TestSet5_TestCase04.java | 23 ++++++++++++++++++
.../testset5/TestSet5_TestCase05.java | 23 ++++++++++++++++++
.../testset5/TestSet5_TestCase06.java | 23 ++++++++++++++++++
.../testset5/TestSet5_TestCase07.java | 23 ++++++++++++++++++
.../testset5/TestSet5_TestCase08.java | 23 ++++++++++++++++++
.../testset5/TestSet5_TestCase09.java | 23 ++++++++++++++++++
.../testset5/TestSet5_TestCase10.java | 23 ++++++++++++++++++
.../lcdb/enhancer/testset5/package-info.java | 7 ++++++
65 files changed, 1394 insertions(+), 1 deletion(-)
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/package-info.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/package-info.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/package-info.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/package-info.java
create mode 100644 src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/package-info.java
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase01.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase01.java
index c329a96..93af2e5 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase01.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase01.java
@@ -1,8 +1,30 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet1_TestCase01 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase02.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase02.java
index 44a6172..f3131ae 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase02.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase02.java
@@ -1,10 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
@Require(types = StringInputProvider.class, values = "[2,7,11,15] 9")
@Require(types = StringInputProvider.class, values = "[3,2,4] 6\n[3,3] 6")
public class TestSet1_TestCase02 extends UnitTestDriver {
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase03.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase03.java
index a37558d..aeea336 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase03.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase03.java
@@ -1,10 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
@Require(types = StringInputProvider.class, values = "[2,7,11,15] 9")
@Require(types = StringInputProvider.class, values = {"[3,2,4] 6", "[3,3] 6"})
public class TestSet1_TestCase03 extends UnitTestDriver {
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase04.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase04.java
index c801ef2..e0da503 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase04.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase04.java
@@ -1,10 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
@Require(types = {
StringInputProvider.class,
StringInputProvider.class
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase05.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase05.java
index 952cf10..2165cd1 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase05.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase05.java
@@ -1,8 +1,30 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet1_TestCase05 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase06.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase06.java
index 1af2614..32e15d6 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase06.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase06.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
@@ -7,6 +24,11 @@
import java.util.Arrays;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet1_TestCase06 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase07.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase07.java
index 7b5ae74..60ee2ba 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase07.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase07.java
@@ -1,8 +1,30 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet1_TestCase07 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase08.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase08.java
index 9b2c482..5690802 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase08.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase08.java
@@ -1,8 +1,30 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet1_TestCase08 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase09.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase09.java
index 8ad1605..91903d7 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase09.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase09.java
@@ -1,11 +1,33 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet1_TestCase09 extends UnitTestDriver {
@Before
public void onBefore() {
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase10.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase10.java
index abeb306..d7dfb76 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase10.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/TestSet1_TestCase10.java
@@ -1,9 +1,31 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset1;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet1_TestCase10 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/package-info.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/package-info.java
new file mode 100644
index 0000000..d705593
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset1/package-info.java
@@ -0,0 +1,6 @@
+/**
+ * Tests for basic function of {@link io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
+package io.github.jidcoo.opto.lcdb.enhancer.testset1;
\ No newline at end of file
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase01.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase01.java
index 459be01..9a0eec1 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase01.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase01.java
@@ -1,10 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
@Require(types = StringInputProvider.class, values = "[[1,1,1],[1,0,1],[1,1,1]]")
public class TestSet2_TestCase01 extends UnitTestDriver {
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase02.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase02.java
index 01d641f..2705977 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase02.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase02.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
@@ -7,6 +24,11 @@
import java.util.*;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
@Require(types = StringInputProvider.class, values = {"\"hit\" \"cog\" [\"hot\",\"dot\",\"dog\",\"lot\",\"log\"," +
"\"cog\"]", "\"hit\" \"cog\" [\"hot\",\"dot\",\"dog\",\"lot\",\"log\"]"})
public class TestSet2_TestCase02 extends UnitTestDriver {
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase03.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase03.java
index 9323dfb..bd67777 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase03.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase03.java
@@ -1,8 +1,30 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet2_TestCase03 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase04.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase04.java
index 571a5dc..e80c8df 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase04.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase04.java
@@ -1,11 +1,33 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
@Require(types = StringInputProvider.class, values = {"[1,2,3]", "[-10,9,20,null,null,15,7]"})
public class TestSet2_TestCase04 extends UnitTestDriver {
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase05.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase05.java
index fcad24a..86c5fed 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase05.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase05.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
@@ -7,6 +24,11 @@
import java.util.Arrays;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
@Require(types = StringInputProvider.class, values = {"2 [2,4,1]", "2 [3,2,6,5,0,3]"})
public class TestSet2_TestCase05 extends UnitTestDriver {
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase06.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase06.java
index 9195523..30be77e 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase06.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase06.java
@@ -1,11 +1,33 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
@Require(types = StringInputProvider.class, values = {"[10,5,15,3,7,null,18] 7 15", "[10,5,15,3,7,13,18,1,null,6] 6 10"})
public class TestSet2_TestCase06 extends UnitTestDriver {
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase07.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase07.java
index 0ee496e..40766c8 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase07.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase07.java
@@ -1,8 +1,30 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet2_TestCase07 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase08.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase08.java
index 717e5f7..ebb2bcf 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase08.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase08.java
@@ -1,11 +1,33 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet2_TestCase08 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase09.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase09.java
index 8a7d64b..a1311fd 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase09.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase09.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
@@ -8,6 +25,11 @@
import java.util.List;
import java.util.PriorityQueue;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet2_TestCase09 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase10.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase10.java
index fbe980b..353fe7d 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase10.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/TestSet2_TestCase10.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset2;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
@@ -8,6 +25,11 @@
import java.util.List;
import java.util.Map;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
public class TestSet2_TestCase10 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/package-info.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/package-info.java
new file mode 100644
index 0000000..9043293
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset2/package-info.java
@@ -0,0 +1,6 @@
+/**
+ * Tests for basic function of {@link io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer}.
+ *
+ * @author Jidcoo
+ */
+package io.github.jidcoo.opto.lcdb.enhancer.testset2;
\ No newline at end of file
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase01.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase01.java
index 60145b8..c656e2b 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase01.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase01.java
@@ -1,9 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link ListNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet3_TestCase01 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase02.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase02.java
index b125bbd..3d8740d 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase02.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase02.java
@@ -1,9 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link ListNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet3_TestCase02 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase03.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase03.java
index be06d84..728df52 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase03.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase03.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import org.junit.Before;
@@ -7,6 +24,12 @@
import java.util.HashSet;
import java.util.Set;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link ListNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet3_TestCase03 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase04.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase04.java
index 6e575c6..66e61db 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase04.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase04.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import org.junit.Before;
@@ -7,6 +24,12 @@
import java.util.HashSet;
import java.util.Set;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link ListNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet3_TestCase04 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase05.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase05.java
index 28a34c4..4579a71 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase05.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase05.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import org.junit.Before;
@@ -7,6 +24,12 @@
import java.util.ArrayDeque;
import java.util.Deque;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link ListNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet3_TestCase05 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase06.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase06.java
index 0ce1878..40b0641 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase06.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase06.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import org.junit.Before;
@@ -9,6 +26,12 @@
import java.util.Deque;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link ListNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet3_TestCase06 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase07.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase07.java
index e66eb4e..aa425e9 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase07.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase07.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
@@ -7,6 +24,12 @@
import java.util.*;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link ListNode} and {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet3_TestCase07 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase08.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase08.java
index cb354ee..007d80a 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase08.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase08.java
@@ -1,9 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link ListNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet3_TestCase08 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase09.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase09.java
index 394c9e8..5c7f04e 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase09.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase09.java
@@ -1,9 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link ListNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet3_TestCase09 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase10.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase10.java
index 022d736..1f60d3a 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase10.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/TestSet3_TestCase10.java
@@ -1,10 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset3;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import org.junit.Before;
-
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link ListNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet3_TestCase10 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/package-info.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/package-info.java
new file mode 100644
index 0000000..a87c1dc
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset3/package-info.java
@@ -0,0 +1,7 @@
+/**
+ * Tests for basic function of {@link io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer}
+ * with data structure {@link io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode}.
+ *
+ * @author Jidcoo
+ */
+package io.github.jidcoo.opto.lcdb.enhancer.testset3;
\ No newline at end of file
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase01.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase01.java
index b6f45a2..c9ccbd5 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase01.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase01.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.ConsoleInputProvider;
@@ -9,6 +26,12 @@
import java.util.HashMap;
import java.util.Map;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
@Require(types = ConsoleInputProvider.class)
@Require(types = ConsoleOutputConsumer.class)
public class TestSet4_TestCase01 extends UnitTestDriver {
@@ -26,6 +49,7 @@ class LRUCache {
private int size;
private int capacity;
private DLinkedNode head, tail;
+
public LRUCache(int capacity) {
this.size = 0;
this.capacity = capacity;
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase02.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase02.java
index 7448347..aadd1ba 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase02.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase02.java
@@ -1,11 +1,34 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
import java.util.Deque;
import java.util.LinkedList;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase02 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase03.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase03.java
index a149ced..bdaa9a4 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase03.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase03.java
@@ -1,8 +1,31 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase03 extends UnitTestDriver {
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase04.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase04.java
index 933dec8..f6c2f71 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase04.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase04.java
@@ -1,8 +1,31 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase04 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase05.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase05.java
index d28a426..f6f016b 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase05.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase05.java
@@ -1,8 +1,31 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase05 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase06.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase06.java
index f09870a..8fabccc 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase06.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase06.java
@@ -1,8 +1,31 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase06 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase07.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase07.java
index 04db4e7..7a5012c 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase07.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase07.java
@@ -1,10 +1,33 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.core.io.builtin.StringInputProvider;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
@Require(types = StringInputProvider.class,
values = "[\"MyCircularDeque\", \"insertLast\", \"insertLast\", \"insertFront\", \"insertFront\", " +
"\"getRear\", " +
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase08.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase08.java
index e0143e5..5dceaf4 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase08.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase08.java
@@ -1,8 +1,31 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase08 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase09.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase09.java
index ff8757a..077e3ae 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase09.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase09.java
@@ -1,11 +1,34 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
import java.util.HashMap;
import java.util.Map;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase09 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase10.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase10.java
index 75ab01d..54c52aa 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase10.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase10.java
@@ -1,10 +1,33 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
import java.util.PriorityQueue;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase10 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase11.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase11.java
index f3c6325..0ed9823 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase11.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase11.java
@@ -1,8 +1,31 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase11 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase12.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase12.java
index 7733a97..4469068 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase12.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase12.java
@@ -1,8 +1,31 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase12 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase13.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase13.java
index e17f628..4f72679 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase13.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase13.java
@@ -1,8 +1,31 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase13 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase14.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase14.java
index dfc5197..f42463e 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase14.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase14.java
@@ -1,11 +1,34 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase14 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase15.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase15.java
index b70d95d..ea237ca 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase15.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase15.java
@@ -1,11 +1,34 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
import java.util.LinkedList;
import java.util.Queue;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase15 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase16.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase16.java
index a14b587..2112e9e 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase16.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase16.java
@@ -1,10 +1,33 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
import java.util.*;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase16 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase17.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase17.java
index 1318e4b..3fb6685 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase17.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase17.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
@@ -8,6 +25,12 @@
import java.util.Map;
import java.util.Set;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase17 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase18.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase18.java
index 53172cc..9bbf786 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase18.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase18.java
@@ -1,11 +1,34 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase18 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase19.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase19.java
index 917399b..a9e98f6 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase19.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase19.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
@@ -8,6 +25,12 @@
import java.util.List;
import java.util.Map;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase19 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase20.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase20.java
index 7b4e772..06109d0 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase20.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/TestSet4_TestCase20.java
@@ -1,11 +1,34 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset4;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import org.junit.Before;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
public class TestSet4_TestCase20 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/package-info.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/package-info.java
new file mode 100644
index 0000000..d0a4d13
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset4/package-info.java
@@ -0,0 +1,7 @@
+/**
+ * Tests for basic function of {@link io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer}
+ * with data structure design problem.
+ *
+ * @author Jidcoo
+ */
+package io.github.jidcoo.opto.lcdb.enhancer.testset4;
\ No newline at end of file
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase01.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase01.java
index 19552d1..c3e8415 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase01.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase01.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
@@ -7,6 +24,12 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet5_TestCase01 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase02.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase02.java
index b9f5b53..bd8d215 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase02.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase02.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
@@ -7,6 +24,12 @@
import java.util.HashMap;
import java.util.Map;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet5_TestCase02 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase03.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase03.java
index 8118777..4952b71 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase03.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase03.java
@@ -1,10 +1,33 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.ListNode;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet5_TestCase03 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase04.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase04.java
index 53da218..4428f81 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase04.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase04.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
@@ -7,6 +24,12 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet5_TestCase04 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase05.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase05.java
index 73c6390..a02d109 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase05.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase05.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
@@ -9,6 +26,12 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet5_TestCase05 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase06.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase06.java
index 8c5d7f8..e5340cd 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase06.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase06.java
@@ -1,9 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet5_TestCase06 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase07.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase07.java
index 3a1e1de..82e846f 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase07.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase07.java
@@ -1,9 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet5_TestCase07 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase08.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase08.java
index 6d58bcc..e30360d 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase08.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase08.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
@@ -7,6 +24,12 @@
import java.util.ArrayDeque;
import java.util.Deque;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet5_TestCase08 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase09.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase09.java
index 0826bd4..46c2d5d 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase09.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase09.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
@@ -7,6 +24,12 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet5_TestCase09 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase10.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase10.java
index 08ca4cc..0a9a980 100644
--- a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase10.java
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/TestSet5_TestCase10.java
@@ -1,9 +1,32 @@
+/*
+ * Copyright (C) 2024-2026 Jidcoo(https://github.com/jidcoo).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package io.github.jidcoo.opto.lcdb.enhancer.testset5;
+import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.UnitTestDriver;
import io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode;
import org.junit.Before;
+/**
+ * Tests for basic function of {@link LeetcodeJavaDebugEnhancer}
+ * with data structure {@link TreeNode}.
+ *
+ * @author Jidcoo
+ */
public class TestSet5_TestCase10 extends UnitTestDriver {
@Before
diff --git a/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/package-info.java b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/package-info.java
new file mode 100644
index 0000000..2a2a80f
--- /dev/null
+++ b/src/test/java/io/github/jidcoo/opto/lcdb/enhancer/testset5/package-info.java
@@ -0,0 +1,7 @@
+/**
+ * Tests for basic function of {@link io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer}
+ * with data structure {@link io.github.jidcoo.opto.lcdb.enhancer.base.struct.TreeNode}.
+ *
+ * @author Jidcoo
+ */
+package io.github.jidcoo.opto.lcdb.enhancer.testset5;
\ No newline at end of file
From 18761dc6d2b675e1f03c302f36374932b9c34c01 Mon Sep 17 00:00:00 2001
From: Jidcoo <1337753396@qq.com>
Date: Sun, 9 Mar 2025 15:25:34 +0800
Subject: [PATCH 05/32] JDK dynamic proxy upgrade.
---
.../enhancer/LeetcodeJavaDebugEnhancer.java | 59 ++--
.../lcdb/enhancer/base/LeetcodeInvoker.java | 9 +
.../LeetcodeJavaDebugEnhanceProcessor.java | 7 +-
.../executor/ConstructorLeetcodeInvoker.java | 28 +-
.../core/executor/MethodLeetcodeInvoker.java | 12 +
...ataStructureDesignScenePipelineRunner.java | 13 -
.../LeetcodeJavaDebugEnhancerPipeline.java | 57 ++++
...odeJavaDebugEnhancerPipelineProcessor.java | 48 +---
.../core/proxy/DebugEnhancerProxy.java | 254 ------------------
.../core/proxy/EnhancerProxyFactory.java | 71 +++++
.../core/proxy/EnhancerProxyHandler.java | 143 ++++++++++
.../proxy/ProxyPointInterceptorManager.java | 19 +-
.../core/proxy/ProxyPointParameterView.java | 4 +-
.../payload/EnhancerPayloadInterceptor.java | 96 +++++++
.../require/io/AbsIORequireSupporter.java | 10 +-
15 files changed, 458 insertions(+), 372 deletions(-)
delete mode 100644 src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/proxy/DebugEnhancerProxy.java
create mode 100644 src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/proxy/EnhancerProxyFactory.java
create mode 100644 src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/proxy/EnhancerProxyHandler.java
create mode 100644 src/main/java/io/github/jidcoo/opto/lcdb/enhancer/func/payload/EnhancerPayloadInterceptor.java
diff --git a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/LeetcodeJavaDebugEnhancer.java b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/LeetcodeJavaDebugEnhancer.java
index c8e8b06..afd6681 100644
--- a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/LeetcodeJavaDebugEnhancer.java
+++ b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/LeetcodeJavaDebugEnhancer.java
@@ -30,39 +30,19 @@
/**
*
Let's start our dreams here! [↖(^ω^)↗]
*
- *
LeetcodeJavaDebugEnhancer is a debugging enhanced startup class.
+ *
LeetcodeJavaDebugEnhancer is a debugging enhanced startup interface class.
*
A public algorithm class is called Algorithm-Target(AT).
- *
Notice: All AT that require debugging must extends from this class!!!
+ *
Notice: All AT that require debugging must implement this interface!!!
If you need to use a method in AT as a starting point for
- * debugging enhancements, please provide an instance of that method. And
- * then the {@link LeetcodeJavaDebugEnhancer} will start from that point.
- *
- *
If the method returns null, the {@link LeetcodeJavaDebugEnhancer} will look for
- * the internal class Solution in AT and find a suitable startup point
- * from Solution as a debugging enhancement startup point.
- *
- *
When the AT is a data structure design class, it is
- * necessary to return a non-null debugging enhancement startup point. Otherwise,
- * the {@link LeetcodeJavaDebugEnhancer} will not be able to start normally
- * with enhanced performance
- *
- * @return the enhancements point.
- */
- public Method getEnhancementPoint() {
- return null;
- }
+ String VERSION = "1.0.3";
/**
*
If you need to customize an input provider, please return a valid instance of
@@ -74,7 +54,7 @@ public Method getEnhancementPoint() {
*
* @return the input provider.
*/
- public InputProvider getInputProvider() {
+ default InputProvider getInputProvider() {
return null;
}
@@ -88,7 +68,7 @@ public InputProvider getInputProvider() {
*
* @return the output consumer.
*/
- public OutputConsumer getOutputConsumer() {
+ default OutputConsumer getOutputConsumer() {
return null;
}
@@ -100,7 +80,7 @@ public OutputConsumer getOutputConsumer() {
*
* @return a list of printing strategies
*/
- public List> getOutputPrintStrategies() {
+ default List> getOutputPrintStrategies() {
return null;
}
@@ -117,26 +97,39 @@ public List> getOutputPrintStrategies() {
* @see Level#WARNING
* @see Level#INFO
*/
- public Level getEnhancerLogLevel() {
+ default Level getEnhancerLogLevel() {
return Level.OFF;
}
+ /**
+ * Return the custom enhancer payload.
+ *
+ *
For example, if you want to debug an outer algorithm solution
+ * instead of an inner algorithm solution, you can use this api to
+ * specify the outer algorithm solution class.
+ *
+ * @return the Enhancer payload class.
+ * @since 1.0.3
+ */
+ default Class> getEnhancerPayload() {
+ return null;
+ }
+
/**
* Return the LeetcodeJavaDebugEnhancer version.
*
* @return the LeetcodeJavaDebugEnhancer version.
*/
- public final String getEnhancerVersion() {
+ static String getEnhancerVersion() {
return VERSION;
}
/**
- * LeetcodeJavaDebugEnhancer starting main point.
+ * LeetcodeJavaDebugEnhancer running point.
*
- * @param args start args.
+ * @param __AT__ the AT name.
*/
- public static void main(String[] args) {
- String __AT__ = System.getProperty("sun.java.command");
+ static void run(String __AT__) {
System.out.println("LeetcodeJavaDebugEnhancer[" + VERSION + "] started.");
if (!"io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer".equals(__AT__)) {
try {
diff --git a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/base/LeetcodeInvoker.java b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/base/LeetcodeInvoker.java
index 70efdcd..71b2df6 100644
--- a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/base/LeetcodeInvoker.java
+++ b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/base/LeetcodeInvoker.java
@@ -118,4 +118,13 @@ public interface LeetcodeInvoker {
* include type parameters
*/
String toGenericString();
+
+ /**
+ * Verify whether this leetcode invoke is suitable for the specified class.
+ *
+ * @param klass the specified class.
+ * @return true if suitable.
+ * @since 1.0.3
+ */
+ boolean isSuitable(Class> klass);
}
diff --git a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/LeetcodeJavaDebugEnhanceProcessor.java b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/LeetcodeJavaDebugEnhanceProcessor.java
index 89702b8..c8c6ba2 100644
--- a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/LeetcodeJavaDebugEnhanceProcessor.java
+++ b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/LeetcodeJavaDebugEnhanceProcessor.java
@@ -18,9 +18,8 @@
import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.core.pipeline.LeetcodeJavaDebugEnhancerPipelineProcessor;
-import io.github.jidcoo.opto.lcdb.enhancer.core.proxy.DebugEnhancerProxy;
+import io.github.jidcoo.opto.lcdb.enhancer.core.proxy.EnhancerProxyFactory;
import io.github.jidcoo.opto.lcdb.enhancer.utils.EnhancerLogUtil;
-import io.github.jidcoo.opto.lcdb.enhancer.utils.ReflectUtil;
/**
*
LeetcodeJavaDebugEnhanceProcessor is a primary enhancer.
@@ -47,8 +46,8 @@ public final class LeetcodeJavaDebugEnhanceProcessor {
* @param AT the AT class.
*/
public static void process(Class extends LeetcodeJavaDebugEnhancer> AT) throws Exception, Error {
- // Create an AT instance enhancer at first and then wrap it as a proxy(DebugEnhancerProxy since 1.0.2).
- LeetcodeJavaDebugEnhancer enhancer = new DebugEnhancerProxy(ReflectUtil.createInstance(AT));
+ // Create A LeetcodeJavaDebugEnhancer proxy instance by AT Class(EnhancerProxyFactory since 1.0.3).
+ LeetcodeJavaDebugEnhancer enhancer = EnhancerProxyFactory.createEnhancerProxy(AT);
// Setup EnhancerLog log level.
EnhancerLogUtil.setLogLevel(enhancer.getEnhancerLogLevel());
diff --git a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/executor/ConstructorLeetcodeInvoker.java b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/executor/ConstructorLeetcodeInvoker.java
index a7e274c..f55a83a 100644
--- a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/executor/ConstructorLeetcodeInvoker.java
+++ b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/executor/ConstructorLeetcodeInvoker.java
@@ -50,6 +50,11 @@ final class ConstructorLeetcodeInvoker implements LeetcodeInvoker {
*/
private boolean matchingFriendly;
+ /**
+ * Mark whether the class corresponding to the constructor of this class is an inner class.
+ */
+ private boolean isInnerClassConstructor;
+
/**
* Create a ConstructorLeetcodeInvoker instance.
*
@@ -59,6 +64,7 @@ final class ConstructorLeetcodeInvoker implements LeetcodeInvoker {
ConstructorLeetcodeInvoker(Constructor> constructor, Integer id) {
AssertUtil.nonNull(constructor, "The constructor cannot be null.");
this.constructor = constructor;
+ this.isInnerClassConstructor = constructor.getDeclaringClass().getEnclosingClass() != null;
// Make accessible.
this.constructor.setAccessible(true);
this.id = id;
@@ -84,7 +90,7 @@ public Integer getId() {
@Override
public int getParameterCount() {
int parameterCount = this.constructor.getParameterCount();
- if (parameterCount > 0 && matchingFriendly) {
+ if (parameterCount > 0 && matchingFriendly && isInnerClassConstructor) {
return parameterCount - 1;
}
return parameterCount;
@@ -98,7 +104,7 @@ public int getParameterCount() {
@Override
public String getInvokerName() {
String name = this.constructor.getName();
- if (name.contains("$") && matchingFriendly) {
+ if (matchingFriendly && isInnerClassConstructor) {
return name.substring(name.lastIndexOf('$') + 1);
}
return name;
@@ -112,7 +118,7 @@ public String getInvokerName() {
@Override
public Class>[] getParameterTypes() {
Class>[] parameterTypes = this.constructor.getParameterTypes();
- if (parameterTypes.length > 0 && matchingFriendly) {
+ if (parameterTypes.length > 0 && matchingFriendly && isInnerClassConstructor) {
return Arrays.stream(parameterTypes).skip(1).toArray(Class[]::new);
}
return parameterTypes;
@@ -126,7 +132,7 @@ public Class>[] getParameterTypes() {
@Override
public Parameter[] getParameters() {
Parameter[] parameters = this.constructor.getParameters();
- if (parameters.length > 0 && matchingFriendly) {
+ if (parameters.length > 0 && matchingFriendly && isInnerClassConstructor) {
return Arrays.stream(parameters).skip(1).toArray(Parameter[]::new);
}
return parameters;
@@ -154,7 +160,7 @@ public Class> getReturnType() {
@Override
public Object invoke(Object object, Object... args) throws Throwable {
Object[] initArgsArray;
- if (Modifier.isStatic(this.constructor.getDeclaringClass().getModifiers())) {
+ if (!isInnerClassConstructor || Modifier.isStatic(this.constructor.getDeclaringClass().getModifiers())) {
initArgsArray = new Object[args.length];
System.arraycopy(args, 0, initArgsArray, 0, args.length);
} else {
@@ -207,4 +213,16 @@ public Object invoke(Object object, Object... args) throws Throwable {
public String toGenericString() {
return this.constructor.toGenericString();
}
+
+ /**
+ * Verify whether this leetcode invoke is suitable for the specified class.
+ *
+ * @param klass the specified class.
+ * @return true if suitable.
+ * @since 1.0.3
+ */
+ @Override
+ public boolean isSuitable(Class> klass) {
+ return this.constructor.getDeclaringClass() == klass;
+ }
}
diff --git a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/executor/MethodLeetcodeInvoker.java b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/executor/MethodLeetcodeInvoker.java
index eac7bca..2ec5b82 100644
--- a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/executor/MethodLeetcodeInvoker.java
+++ b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/executor/MethodLeetcodeInvoker.java
@@ -173,4 +173,16 @@ public Object invoke(Object object, Object... args) throws Throwable {
public String toGenericString() {
return this.method.toGenericString();
}
+
+ /**
+ * Verify whether this leetcode invoke is suitable for the specified class.
+ *
+ * @param klass the specified class.
+ * @return true if suitable.
+ * @since 1.0.3
+ */
+ @Override
+ public boolean isSuitable(Class> klass) {
+ return this.method.getDeclaringClass() == klass;
+ }
}
diff --git a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/pipeline/DataStructureDesignScenePipelineRunner.java b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/pipeline/DataStructureDesignScenePipelineRunner.java
index 86f1e55..413fefe 100644
--- a/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/pipeline/DataStructureDesignScenePipelineRunner.java
+++ b/src/main/java/io/github/jidcoo/opto/lcdb/enhancer/core/pipeline/DataStructureDesignScenePipelineRunner.java
@@ -16,14 +16,12 @@
package io.github.jidcoo.opto.lcdb.enhancer.core.pipeline;
-import io.github.jidcoo.opto.lcdb.enhancer.LeetcodeJavaDebugEnhancer;
import io.github.jidcoo.opto.lcdb.enhancer.base.LeetcodeInvoker;
import io.github.jidcoo.opto.lcdb.enhancer.base.Require;
import io.github.jidcoo.opto.lcdb.enhancer.core.executor.LeetcodeExecutorFactory;
import io.github.jidcoo.opto.lcdb.enhancer.core.executor.LeetcodeExecutorProcessor;
import io.github.jidcoo.opto.lcdb.enhancer.core.executor.LeetcodeInvokerFactory;
import io.github.jidcoo.opto.lcdb.enhancer.core.parser.InputParserProcessor;
-import io.github.jidcoo.opto.lcdb.enhancer.core.proxy.DebugEnhancerProxy;
import io.github.jidcoo.opto.lcdb.enhancer.utils.AssertUtil;
import io.github.jidcoo.opto.lcdb.enhancer.utils.ContainerCheckUtil;
import io.github.jidcoo.opto.lcdb.enhancer.utils.ReflectUtil;
@@ -112,15 +110,4 @@ List