Merge pull request #15 from cwiki-us-docs/code_bank
Change project for full compile
This commit is contained in:
commit
115ce988f3
1
.idea/.name
generated
1
.idea/.name
generated
@ -1 +0,0 @@
|
|||||||
cwiki-us-demo-tutorials
|
|
13
.idea/compiler.xml
generated
13
.idea/compiler.xml
generated
@ -6,16 +6,15 @@
|
|||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="cwiki-us-demo-tutorials" />
|
<module name="codebank" />
|
||||||
|
<module name="discourse" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel target="1.8">
|
<bytecodeTargetLevel>
|
||||||
<module name="cwiki-us-demo-tutorials" target="11" />
|
<module name="codebank" target="11" />
|
||||||
<module name="cwiki-us-demo-tutorials.spring-batch" target="11" />
|
<module name="discourse" target="11" />
|
||||||
<module name="cwiki-us-demo-tutorials.spring-batch.main" target="11" />
|
|
||||||
<module name="cwiki-us-demo-tutorials.spring-batch.test" target="11" />
|
|
||||||
<module name="lang-tutorial" target="1.5" />
|
|
||||||
<module name="parent-modules" target="11" />
|
<module name="parent-modules" target="11" />
|
||||||
|
<module name="toolkits" target="1.5" />
|
||||||
</bytecodeTargetLevel>
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
2
.idea/encodings.xml
generated
2
.idea/encodings.xml
generated
@ -3,5 +3,7 @@
|
|||||||
<component name="Encoding">
|
<component name="Encoding">
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/toolkits/codebank/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/toolkits/discourse/src/main/java" charset="UTF-8" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
15
.idea/jarRepositories.xml
generated
15
.idea/jarRepositories.xml
generated
@ -1,21 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="BintrayJCenter" />
|
|
||||||
<option name="name" value="BintrayJCenter" />
|
|
||||||
<option name="url" value="https://jcenter.bintray.com/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Central Repository" />
|
<option name="name" value="Central Repository" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="MavenRepo" />
|
|
||||||
<option name="name" value="MavenRepo" />
|
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Maven Central repository" />
|
<option name="name" value="Maven Central repository" />
|
||||||
@ -26,10 +16,5 @@
|
|||||||
<option name="name" value="JBoss Community repository" />
|
<option name="name" value="JBoss Community repository" />
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="maven2" />
|
|
||||||
<option name="name" value="maven2" />
|
|
||||||
<option name="url" value="https://maven.ossez.com/repository/internal" />
|
|
||||||
</remote-repository>
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
65
.idea/libraries-with-intellij-classes.xml
generated
65
.idea/libraries-with-intellij-classes.xml
generated
@ -1,65 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="libraries-with-intellij-classes">
|
|
||||||
<option name="intellijApiContainingLibraries">
|
|
||||||
<list>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="ideaIU" />
|
|
||||||
<option name="groupId" value="com.jetbrains.intellij.idea" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="ideaIU" />
|
|
||||||
<option name="groupId" value="com.jetbrains" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="ideaIC" />
|
|
||||||
<option name="groupId" value="com.jetbrains.intellij.idea" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="ideaIC" />
|
|
||||||
<option name="groupId" value="com.jetbrains" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="pycharmPY" />
|
|
||||||
<option name="groupId" value="com.jetbrains.intellij.pycharm" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="pycharmPY" />
|
|
||||||
<option name="groupId" value="com.jetbrains" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="pycharmPC" />
|
|
||||||
<option name="groupId" value="com.jetbrains.intellij.pycharm" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="pycharmPC" />
|
|
||||||
<option name="groupId" value="com.jetbrains" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="clion" />
|
|
||||||
<option name="groupId" value="com.jetbrains.intellij.clion" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="clion" />
|
|
||||||
<option name="groupId" value="com.jetbrains" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="riderRD" />
|
|
||||||
<option name="groupId" value="com.jetbrains.intellij.rider" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="riderRD" />
|
|
||||||
<option name="groupId" value="com.jetbrains" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="goland" />
|
|
||||||
<option name="groupId" value="com.jetbrains.intellij.goland" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
<LibraryCoordinatesState>
|
|
||||||
<option name="artifactId" value="goland" />
|
|
||||||
<option name="groupId" value="com.jetbrains" />
|
|
||||||
</LibraryCoordinatesState>
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -7,5 +7,5 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK" />
|
||||||
</project>
|
</project>
|
9
.idea/modules.xml
generated
9
.idea/modules.xml
generated
@ -2,13 +2,10 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/cwiki-us-demo-tutorials.iml" filepath="$PROJECT_DIR$/.idea/modules/cwiki-us-demo-tutorials.iml" />
|
<module fileurl="file://$PROJECT_DIR$/toolkits/codebank/codebank.iml" filepath="$PROJECT_DIR$/toolkits/codebank/codebank.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/cwiki-us-demo-tutorials.main.iml" filepath="$PROJECT_DIR$/.idea/modules/cwiki-us-demo-tutorials.main.iml" />
|
<module fileurl="file://$PROJECT_DIR$/toolkits/discourse/discourse.iml" filepath="$PROJECT_DIR$/toolkits/discourse/discourse.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/spring-batch/cwiki-us-demo-tutorials.spring-batch.iml" filepath="$PROJECT_DIR$/.idea/modules/spring-batch/cwiki-us-demo-tutorials.spring-batch.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/spring-batch/cwiki-us-demo-tutorials.spring-batch.main.iml" filepath="$PROJECT_DIR$/.idea/modules/spring-batch/cwiki-us-demo-tutorials.spring-batch.main.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/spring-batch/cwiki-us-demo-tutorials.spring-batch.test.iml" filepath="$PROJECT_DIR$/.idea/modules/spring-batch/cwiki-us-demo-tutorials.spring-batch.test.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/cwiki-us-demo-tutorials.test.iml" filepath="$PROJECT_DIR$/.idea/modules/cwiki-us-demo-tutorials.test.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/parent-modules.iml" filepath="$PROJECT_DIR$/parent-modules.iml" />
|
<module fileurl="file://$PROJECT_DIR$/parent-modules.iml" filepath="$PROJECT_DIR$/parent-modules.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/toolkits/toolkits.iml" filepath="$PROJECT_DIR$/toolkits/toolkits.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
246
.idea/workspace.xml
generated
246
.idea/workspace.xml
generated
@ -4,263 +4,51 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="bc4dcfec-3698-4fde-a6cf-dd08b73f1f06" name="Default Changelist" comment="Update pom file for downloading from central maven repo">
|
<list default="true" id="e4ccec40-1722-49be-ba56-1cba428e2e66" name="Default Changelist" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/algorithm/models/ListNode.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.name" beforeDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/algorithm/models/TreeNode.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/interview/KayakCountUpDown.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/jarRepositories.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/jarRepositories.xml" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/interview/KayakRobotMovement.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/libraries-with-intellij-classes.xml" beforeDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/interview/ManNextFibonacciNumber.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/VariableTest.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/codility/CodilityBinaryGapTest.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/lintcode/LintCode0007SerializeAndDeserializeTest.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/LintcodeTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/LintcodeTest.java" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/lintcode/LintCode0069LevelOrderTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/lintcode/LintCode0102HasCycleTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/lintcode/LintCode0165MergeTwoListsTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/lintcode/LintCode0425LetterCombinationsTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/lintcode/LintCode0433NumIslandsTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/lintcode/LintCode1480DotProductTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/interview/tests/AmazonTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/interview/tests/KayakTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/interview/tests/MassMutual.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/interview/tests/PillPackTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/interview/tests/TennaTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/interview/tests/WayfairTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/interview/tests/others/LambdaEvensTest.java" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/interview/tests/others/MinimumCoinsTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/readme.md" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/ossez/lang/tutorial/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/algorithm/Main.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/ossez/lang/tutorial/models/ListNode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/ossez/lang/tutorial/models/ListNode.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/ossez/lang/tutorial/models/TreeNode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/ossez/lang/tutorial/models/TreeNode.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/ossez/lang/tutorial/objplusclass/CreateObject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/algorithm/objplusclass/CreateObject.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/ossez/lang/tutorial/overview/FreshJuiceEnums.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/algorithm/overview/FreshJuiceEnums.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/ossez/lang/tutorial/overview/HelloWorld.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/algorithm/overview/HelloWorld.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/ossez/lang/tutorial/usecases/VarargsCase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/algorithm/usecases/VarargsCase.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/ossez/lang/tutorial/utils/TreeUtils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/ossez/codebank/algorithml/utils/TreeUtils.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/BitOperationTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/BitOperationTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/LintcodeTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/LintcodeTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/SingletonTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/SingletonTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/TreeTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/codebank/algorithm/tests/TreeTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/VariableTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/VariableTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/codility/CodilityBinaryGapTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/codility/CodilityBinaryGapTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0007SerializeAndDeserializeTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0007SerializeAndDeserializeTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0069LevelOrderTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0069LevelOrderTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0102HasCycleTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0102HasCycleTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0165MergeTwoListsTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0165MergeTwoListsTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0425LetterCombinationsTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0425LetterCombinationsTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0433NumIslandsTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode0433NumIslandsTest.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode1480DotProductTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/com/ossez/lang/tutorial/tests/lintcode/LintCode1480DotProductTest.java" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="CodeStyleSettingsInfer">
|
|
||||||
<option name="done" value="true" />
|
|
||||||
</component>
|
|
||||||
<component name="ExternalProjectsData">
|
|
||||||
<projectState path="$PROJECT_DIR$">
|
|
||||||
<ProjectState />
|
|
||||||
</projectState>
|
|
||||||
</component>
|
|
||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
|
||||||
<map>
|
|
||||||
<entry key="$PROJECT_DIR$" value="current" />
|
|
||||||
</map>
|
|
||||||
</option>
|
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
<component name="GitSEFilterConfiguration">
|
<component name="ProjectId" id="1rgubunw7ryTECA0xroZNQRefbN" />
|
||||||
<file-type-list>
|
|
||||||
<filtered-out-file-type name="LOCAL_BRANCH" />
|
|
||||||
<filtered-out-file-type name="REMOTE_BRANCH" />
|
|
||||||
<filtered-out-file-type name="TAG" />
|
|
||||||
<filtered-out-file-type name="COMMIT_BY_MESSAGE" />
|
|
||||||
</file-type-list>
|
|
||||||
</component>
|
|
||||||
<component name="ProjectCodeStyleSettingsMigration">
|
|
||||||
<option name="version" value="1" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectId" id="1r1Zx6oqLWRPWaxq39M8I4kCZrQ" />
|
|
||||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
|
||||||
<component name="ProjectViewState">
|
<component name="ProjectViewState">
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">
|
<component name="PropertiesComponent">
|
||||||
<property name="Git.Branch.Popup.ShowAllRemotes" value="true" />
|
|
||||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||||
<property name="aspect.path.notification.shown" value="true" />
|
<property name="aspect.path.notification.shown" value="true" />
|
||||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/spring-batch" />
|
<property name="project.structure.last.edited" value="Modules" />
|
||||||
<property name="nodejs_package_manager_path" value="npm" />
|
<property name="project.structure.proportion" value="0.0" />
|
||||||
</component>
|
<property name="project.structure.side.proportion" value="0.0" />
|
||||||
<component name="RecentsManager">
|
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
|
||||||
<recent name="C:\WorkDir\GitHub\cwiki-us-docs\java-tutorials\spring-batch" />
|
|
||||||
<recent name="C:\WorkDir\GitHub\cwiki-us-docs\java-tutorials\toolkits\discourse" />
|
|
||||||
<recent name="C:\WorkDir\GitHub\cwiki-us-docs\java-tutorials\toolkits" />
|
|
||||||
<recent name="C:\WorkDir\GitHub\cwiki-us-docs\java-tutorials\toolkits\test\java\com\ossez\edtestbank\service\test" />
|
|
||||||
<recent name="C:\WorkDir\GitHub\cwiki-us-docs\java-tutorials\src\test" />
|
|
||||||
</key>
|
|
||||||
<key name="MoveFile.RECENT_KEYS">
|
|
||||||
<recent name="C:\WorkDir\GitHub\cwiki-us-docs\java-tutorials\src\test\java\com\ossez\lang\tutorial\tests" />
|
|
||||||
</key>
|
|
||||||
</component>
|
|
||||||
<component name="RunManager">
|
|
||||||
<configuration default="true" type="ArquillianTestNG" factoryName="" nameIsGenerated="true">
|
|
||||||
<option name="arquillianRunConfiguration">
|
|
||||||
<value>
|
|
||||||
<option name="containerStateName" value="" />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="TEST_OBJECT" value="CLASS" />
|
|
||||||
<properties />
|
|
||||||
<listeners />
|
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
</component>
|
</component>
|
||||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
<component name="TaskManager">
|
<component name="TaskManager">
|
||||||
<task active="true" id="Default" summary="Default task">
|
<task active="true" id="Default" summary="Default task">
|
||||||
<changelist id="bc4dcfec-3698-4fde-a6cf-dd08b73f1f06" name="Default Changelist" comment="" />
|
<changelist id="e4ccec40-1722-49be-ba56-1cba428e2e66" name="Default Changelist" comment="" />
|
||||||
<created>1618145802441</created>
|
<created>1619410137650</created>
|
||||||
<option name="number" value="Default" />
|
<option name="number" value="Default" />
|
||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1618145802441</updated>
|
<updated>1619410137650</updated>
|
||||||
<workItem from="1618145805266" duration="1634000" />
|
<workItem from="1619410141685" duration="105000" />
|
||||||
<workItem from="1618147512704" duration="6933000" />
|
|
||||||
<workItem from="1618246818887" duration="17236000" />
|
|
||||||
<workItem from="1618429441584" duration="12732000" />
|
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="更新 POM 文件">
|
|
||||||
<created>1618147556538</created>
|
|
||||||
<option name="number" value="00001" />
|
|
||||||
<option name="presentableId" value="LOCAL-00001" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618147556538</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00002" summary="Discourse Topic import">
|
|
||||||
<created>1618147882644</created>
|
|
||||||
<option name="number" value="00002" />
|
|
||||||
<option name="presentableId" value="LOCAL-00002" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618147882644</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00003" summary="项目的 POM 配置文件 # Conflicts: #	pom.xml">
|
|
||||||
<created>1618151038853</created>
|
|
||||||
<option name="number" value="00003" />
|
|
||||||
<option name="presentableId" value="LOCAL-00003" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618151038853</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00004" summary="Discourse">
|
|
||||||
<created>1618157753954</created>
|
|
||||||
<option name="number" value="00004" />
|
|
||||||
<option name="presentableId" value="LOCAL-00004" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618157753954</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00005" summary="添加忽略文件的内容">
|
|
||||||
<created>1618499169408</created>
|
|
||||||
<option name="number" value="00005" />
|
|
||||||
<option name="presentableId" value="LOCAL-00005" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618499169408</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00006" summary="完成所有的文件的提交,以便于下一步的代码演示和开发">
|
|
||||||
<created>1618499203125</created>
|
|
||||||
<option name="number" value="00006" />
|
|
||||||
<option name="presentableId" value="LOCAL-00006" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618499203125</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00007" summary="adjust the pom to make project can be compile">
|
|
||||||
<created>1618503350719</created>
|
|
||||||
<option name="number" value="00007" />
|
|
||||||
<option name="presentableId" value="LOCAL-00007" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618503350719</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00008" summary="DiscourseImportTest move to different project">
|
|
||||||
<created>1618503445699</created>
|
|
||||||
<option name="number" value="00008" />
|
|
||||||
<option name="presentableId" value="LOCAL-00008" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618503445699</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00009" summary="Change the compiler version to 3.7.0 version">
|
|
||||||
<created>1618509340144</created>
|
|
||||||
<option name="number" value="00009" />
|
|
||||||
<option name="presentableId" value="LOCAL-00009" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618509340144</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00010" summary="提交 OSSRH 的提交地址">
|
|
||||||
<created>1618515214208</created>
|
|
||||||
<option name="number" value="00010" />
|
|
||||||
<option name="presentableId" value="LOCAL-00010" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618515214208</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00011" summary="Add name and URL before push to OSSRH">
|
|
||||||
<created>1618519278569</created>
|
|
||||||
<option name="number" value="00011" />
|
|
||||||
<option name="presentableId" value="LOCAL-00011" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618519278569</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00012" summary="Upgrade to using JDK 11">
|
|
||||||
<created>1618519439477</created>
|
|
||||||
<option name="number" value="00012" />
|
|
||||||
<option name="presentableId" value="LOCAL-00012" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618519439477</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00013" summary="Change name and description">
|
|
||||||
<created>1618519836247</created>
|
|
||||||
<option name="number" value="00013" />
|
|
||||||
<option name="presentableId" value="LOCAL-00013" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1618519836247</updated>
|
|
||||||
</task>
|
|
||||||
<option name="localTasksCounter" value="14" />
|
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
|
||||||
<option name="TAB_STATES">
|
|
||||||
<map>
|
|
||||||
<entry key="MAIN">
|
|
||||||
<value>
|
|
||||||
<State />
|
|
||||||
</value>
|
|
||||||
</entry>
|
|
||||||
</map>
|
|
||||||
</option>
|
|
||||||
<option name="oldMeFiltersMigrated" value="true" />
|
|
||||||
</component>
|
|
||||||
<component name="VcsManagerConfiguration">
|
|
||||||
<MESSAGE value="更新 POM 文件" />
|
|
||||||
<MESSAGE value="Discourse Topic import" />
|
|
||||||
<MESSAGE value="项目的 POM 配置文件 # Conflicts: #	pom.xml" />
|
|
||||||
<MESSAGE value="Discourse" />
|
|
||||||
<MESSAGE value="添加忽略文件的内容" />
|
|
||||||
<MESSAGE value="完成所有的文件的提交,以便于下一步的代码演示和开发" />
|
|
||||||
<MESSAGE value="adjust the pom to make project can be compile" />
|
|
||||||
<MESSAGE value="DiscourseImportTest move to different project" />
|
|
||||||
<MESSAGE value="Change the compiler version to 3.7.0 version" />
|
|
||||||
<MESSAGE value="提交 OSSRH 的提交地址" />
|
|
||||||
<MESSAGE value="Add name and URL before push to OSSRH" />
|
|
||||||
<MESSAGE value="Upgrade to using JDK 11" />
|
|
||||||
<MESSAGE value="Change name and description" />
|
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Change name and description" />
|
|
||||||
</component>
|
|
||||||
</project>
|
</project>
|
9
pom.xml
9
pom.xml
@ -38,6 +38,10 @@
|
|||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>toolkits</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- Generic properties -->
|
<!-- Generic properties -->
|
||||||
<java.version>11</java.version>
|
<java.version>11</java.version>
|
||||||
@ -75,8 +79,8 @@
|
|||||||
<!-- LOG -->
|
<!-- LOG -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-slf4j-impl</artifactId>
|
<artifactId>log4j-slf4j18-impl</artifactId>
|
||||||
<version>2.11.0</version>
|
<version>2.14.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- APACHE COMMONS -->
|
<!-- APACHE COMMONS -->
|
||||||
@ -305,6 +309,7 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<snapshotRepository>
|
<snapshotRepository>
|
||||||
<id>ossrh</id>
|
<id>ossrh</id>
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package com.ossez.codebank.algorithm.models;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ListNode {
|
|
||||||
public int val;
|
|
||||||
public ListNode next;
|
|
||||||
|
|
||||||
public ListNode(int x) {
|
|
||||||
val = x;
|
|
||||||
next = null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.ossez.codebank.algorithm.models;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TreeNode {
|
|
||||||
public int val;
|
|
||||||
public TreeNode left, right;
|
|
||||||
|
|
||||||
public TreeNode(int val) {
|
|
||||||
this.val = val;
|
|
||||||
this.left = this.right = null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package com.ossez.codebank.algorithm.tests.codility;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* More details about question see link below
|
|
||||||
* <ul>
|
|
||||||
* <li>@see <a href= "https://www.cwiki.us/display/ITCLASSIFICATION/Binary+Gap">https://www.cwiki.us/display/ITCLASSIFICATION/Binary+Gap</a>
|
|
||||||
* </li>
|
|
||||||
* </ul>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class CodilityBinaryGapTest {
|
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(CodilityBinaryGapTest.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMain() {
|
|
||||||
logger.debug("BEGIN");
|
|
||||||
|
|
||||||
int N = 529;
|
|
||||||
String intStr = Integer.toBinaryString(N);
|
|
||||||
|
|
||||||
intStr = intStr.replace("1", "#1#");
|
|
||||||
|
|
||||||
String[] strArray = intStr.split("1");
|
|
||||||
|
|
||||||
int maxCount = 0;
|
|
||||||
for (int i = 0; i < strArray.length; i++) {
|
|
||||||
String checkStr = strArray[i];
|
|
||||||
int countLength = 0;
|
|
||||||
|
|
||||||
if (checkStr.length() > 2 && checkStr.startsWith("#") && checkStr.endsWith("#")) {
|
|
||||||
checkStr = checkStr.replace("#", "");
|
|
||||||
countLength = checkStr.length();
|
|
||||||
|
|
||||||
if (maxCount < countLength) {
|
|
||||||
maxCount = countLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug("MAX COUNT: [{}]", maxCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,131 +0,0 @@
|
|||||||
package com.ossez.codebank.algorithm.tests.lintcode;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.ossez.codebank.algorithm.models.TreeNode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 7
|
|
||||||
* <ul>
|
|
||||||
* <li>@see <a href=
|
|
||||||
* "https://www.cwiki.us/display/ITCLASSIFICATION/Serialize+and+Deserialize+Binary+Tree">https://www.cwiki.us/display/ITCLASSIFICATION/Serialize+and+Deserialize+Binary+Tree</a>
|
|
||||||
* <li>@see<a href=
|
|
||||||
* "https://www.lintcode.com/problem/serialize-and-deserialize-binary-tree">https://www.lintcode.com/problem/serialize-and-deserialize-binary-tree</a>
|
|
||||||
* </ul>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class LintCode0007SerializeAndDeserializeTest {
|
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(LintCode0007SerializeAndDeserializeTest.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMain() {
|
|
||||||
logger.debug("BEGIN");
|
|
||||||
String data = "{3,9,20,#,#,15,7}";
|
|
||||||
|
|
||||||
System.out.println(serialize(deserialize(data)));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserialize from array to tree
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private TreeNode deserialize(String data) {
|
|
||||||
// NULL CHECK
|
|
||||||
if (data.equals("{}")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<TreeNode> treeList = new ArrayList<TreeNode>();
|
|
||||||
|
|
||||||
data = data.replace("{", "");
|
|
||||||
data = data.replace("}", "");
|
|
||||||
String[] vals = data.split(",");
|
|
||||||
|
|
||||||
// INSERT ROOT
|
|
||||||
TreeNode root = new TreeNode(Integer.parseInt(vals[0]));
|
|
||||||
treeList.add(root);
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
boolean isLeftChild = true;
|
|
||||||
for (int i = 1; i < vals.length; i++) {
|
|
||||||
if (!vals[i].equals("#")) {
|
|
||||||
TreeNode node = new TreeNode(Integer.parseInt(vals[i]));
|
|
||||||
if (isLeftChild) {
|
|
||||||
treeList.get(index).left = node;
|
|
||||||
} else {
|
|
||||||
treeList.get(index).right = node;
|
|
||||||
}
|
|
||||||
treeList.add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
// LEVEL
|
|
||||||
if (!isLeftChild) {
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MOVE TO RIGHT OR NEXT LEVEL
|
|
||||||
isLeftChild = !isLeftChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
return root;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param root
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String serialize(TreeNode root) {
|
|
||||||
// write your code here
|
|
||||||
if (root == null) {
|
|
||||||
return "{}";
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<TreeNode> queue = new ArrayList<TreeNode>();
|
|
||||||
queue.add(root);
|
|
||||||
|
|
||||||
for (int i = 0; i < queue.size(); i++) {
|
|
||||||
TreeNode node = queue.get(i);
|
|
||||||
if (node == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
queue.add(node.left);
|
|
||||||
queue.add(node.right);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (queue.get(queue.size() - 1) == null) {
|
|
||||||
queue.remove(queue.size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("{");
|
|
||||||
sb.append(queue.get(0).val);
|
|
||||||
for (int i = 1; i < queue.size(); i++) {
|
|
||||||
if (queue.get(i) == null) {
|
|
||||||
sb.append(",#");
|
|
||||||
} else {
|
|
||||||
sb.append(",");
|
|
||||||
sb.append(queue.get(i).val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sb.append("}");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,124 +0,0 @@
|
|||||||
package com.ossez.codebank.algorithm.tests.lintcode;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Queue;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.ossez.codebank.algorithm.models.TreeNode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 69
|
|
||||||
* <ul>
|
|
||||||
* <li>@see <a href=
|
|
||||||
* "https://www.cwiki.us/display/ITCLASSIFICATION/Binary+Tree+Level+Order+Traversal">https://www.cwiki.us/display/ITCLASSIFICATION/Binary+Tree+Level+Order+Traversal</a>
|
|
||||||
* <li>@see<a href=
|
|
||||||
* "https://www.lintcode.com/problem/binary-tree-level-order-traversal">https://www.lintcode.com/problem/binary-tree-level-order-traversal</a>
|
|
||||||
* </ul>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class LintCode0069LevelOrderTest {
|
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(LintCode0069LevelOrderTest.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMain() {
|
|
||||||
logger.debug("BEGIN");
|
|
||||||
String data = "{3,9,20,#,#,15,7}";
|
|
||||||
|
|
||||||
TreeNode tn = deserialize(data);
|
|
||||||
System.out.println(levelOrder(tn));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserialize from array to tree
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private TreeNode deserialize(String data) {
|
|
||||||
// NULL CHECK
|
|
||||||
if (data.equals("{}")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<TreeNode> treeList = new ArrayList<TreeNode>();
|
|
||||||
|
|
||||||
data = data.replace("{", "");
|
|
||||||
data = data.replace("}", "");
|
|
||||||
String[] vals = data.split(",");
|
|
||||||
|
|
||||||
// INSERT ROOT
|
|
||||||
TreeNode root = new TreeNode(Integer.parseInt(vals[0]));
|
|
||||||
treeList.add(root);
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
boolean isLeftChild = true;
|
|
||||||
for (int i = 1; i < vals.length; i++) {
|
|
||||||
if (!vals[i].equals("#")) {
|
|
||||||
TreeNode node = new TreeNode(Integer.parseInt(vals[i]));
|
|
||||||
if (isLeftChild) {
|
|
||||||
treeList.get(index).left = node;
|
|
||||||
} else {
|
|
||||||
treeList.get(index).right = node;
|
|
||||||
}
|
|
||||||
treeList.add(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
// LEVEL
|
|
||||||
if (!isLeftChild) {
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MOVE TO RIGHT OR NEXT LEVEL
|
|
||||||
isLeftChild = !isLeftChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
return root;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<List<Integer>> levelOrder(TreeNode root) {
|
|
||||||
Queue<TreeNode> queue = new LinkedList<TreeNode>();
|
|
||||||
List<List<Integer>> rs = new ArrayList<List<Integer>>();
|
|
||||||
|
|
||||||
// NULL CHECK
|
|
||||||
if (root == null) {
|
|
||||||
return rs;
|
|
||||||
}
|
|
||||||
|
|
||||||
queue.offer(root);
|
|
||||||
|
|
||||||
while (!queue.isEmpty()) {
|
|
||||||
int length = queue.size();
|
|
||||||
List<Integer> list = new ArrayList<Integer>();
|
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
TreeNode curTN = queue.poll();
|
|
||||||
list.add(curTN.val);
|
|
||||||
if (curTN.left != null) {
|
|
||||||
queue.offer(curTN.left);
|
|
||||||
}
|
|
||||||
if (curTN.right != null) {
|
|
||||||
queue.offer(curTN.right);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rs.add(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rs;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package com.ossez.codebank.algorithm.tests.lintcode;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.ossez.codebank.algorithm.models.ListNode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 102
|
|
||||||
* <ul>
|
|
||||||
* <li>@see <a href=
|
|
||||||
* "https://www.cwiki.us/display/ITCLASSIFICATION/Linked+List+Cycle">https://www.cwiki.us/display/ITCLASSIFICATION/Linked+List+Cycle</a>
|
|
||||||
* <li>@see<a href= "https://www.lintcode.com/problem/linked-list-cycle/">https://www.lintcode.com/problem/linked-list-cycle/</a>
|
|
||||||
* </ul>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class LintCode0102HasCycleTest {
|
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(LintCode0102HasCycleTest.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMain() {
|
|
||||||
logger.debug("BEGIN");
|
|
||||||
// INIT LINKED LIST
|
|
||||||
ListNode head = new ListNode(1);
|
|
||||||
head.next = new ListNode(2);
|
|
||||||
head.next.next = new ListNode(3);
|
|
||||||
head.next.next.next = new ListNode(4);
|
|
||||||
|
|
||||||
// CREATE A LOOP
|
|
||||||
head.next.next.next.next = head.next.next.next;
|
|
||||||
|
|
||||||
boolean retResult = false;
|
|
||||||
|
|
||||||
// LIKED LIST MAY NULL:
|
|
||||||
if (!(head == null || head.next == null)) {
|
|
||||||
ListNode s = head;
|
|
||||||
ListNode f = head.next;
|
|
||||||
|
|
||||||
while (f.next != null && f.next.next != null) {
|
|
||||||
|
|
||||||
s = s.next;
|
|
||||||
f = f.next.next;
|
|
||||||
|
|
||||||
if (f == s) {
|
|
||||||
retResult = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println(retResult);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
package com.ossez.codebank.algorithm.tests.lintcode;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.ossez.codebank.algorithm.models.ListNode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 102
|
|
||||||
* <ul>
|
|
||||||
* <li>@see <a href=
|
|
||||||
* "https://www.cwiki.us/display/ITCLASSIFICATION/Linked+List+Cycle">https://www.cwiki.us/display/ITCLASSIFICATION/Linked+List+Cycle</a>
|
|
||||||
* <li>@see<a href= "https://www.lintcode.com/problem/linked-list-cycle/">https://www.lintcode.com/problem/linked-list-cycle/</a>
|
|
||||||
* </ul>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class LintCode0165MergeTwoListsTest {
|
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(LintCode0165MergeTwoListsTest.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMain() {
|
|
||||||
logger.debug("BEGIN");
|
|
||||||
// INIT LINKED LIST l1
|
|
||||||
ListNode l1 = new ListNode(1);
|
|
||||||
l1.next = new ListNode(3);
|
|
||||||
l1.next.next = new ListNode(8);
|
|
||||||
l1.next.next.next = new ListNode(11);
|
|
||||||
l1.next.next.next.next = new ListNode(15);
|
|
||||||
|
|
||||||
// INIT LINKED LIST l2
|
|
||||||
ListNode l2 = new ListNode(2);
|
|
||||||
|
|
||||||
// RETURN RESULT
|
|
||||||
ListNode retResult = new ListNode(0);
|
|
||||||
|
|
||||||
// NULL CHECK
|
|
||||||
// if (l1 == null && l2 == null) {
|
|
||||||
// retResult = null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (l1 == null) {
|
|
||||||
// retResult = l2;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (l2 == null) {
|
|
||||||
// retResult = l1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// MERGE
|
|
||||||
retResult = new ListNode(0);
|
|
||||||
ListNode tmpNode = new ListNode(0);
|
|
||||||
retResult = tmpNode;
|
|
||||||
while (l1 != null & l2 != null) {
|
|
||||||
if (l1.val <= l2.val) {
|
|
||||||
tmpNode.next = l1;
|
|
||||||
l1 = l1.next;
|
|
||||||
} else {
|
|
||||||
tmpNode.next = l2;
|
|
||||||
l2 = l2.next;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpNode = tmpNode.next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (l1 == null) {
|
|
||||||
tmpNode.next = l2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (l2 == null) {
|
|
||||||
tmpNode.next = l1;
|
|
||||||
}
|
|
||||||
|
|
||||||
retResult = retResult.next;
|
|
||||||
|
|
||||||
System.out.println(retResult.val);
|
|
||||||
System.out.println(retResult.next.val);
|
|
||||||
System.out.println(retResult.next.next.val);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
package com.ossez.codebank.algorithm.tests.lintcode;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 425
|
|
||||||
* <ul>
|
|
||||||
* <li>@see <a href=
|
|
||||||
* "https://www.cwiki.us/display/ITCLASSIFICATION/Letter+Combinations+of+a+Phone+Number">https://www.cwiki.us/display/ITCLASSIFICATION/Letter+Combinations+of+a+Phone+Number</a>
|
|
||||||
* <li>@see<a href=
|
|
||||||
* "https://www.lintcode.com/problem/letter-combinations-of-a-phone-number/description">https://www.lintcode.com/problem/letter-combinations-of-a-phone-number/description</a>
|
|
||||||
* </ul>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class LintCode0425LetterCombinationsTest {
|
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(LintCode0425LetterCombinationsTest.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMain() {
|
|
||||||
logger.debug("LetterCombinationsTest");
|
|
||||||
String digits = "23";
|
|
||||||
|
|
||||||
HashMap<String, String> phoneKeyMap = new HashMap<String, String>();
|
|
||||||
phoneKeyMap.put("0", "");
|
|
||||||
phoneKeyMap.put("1", "");
|
|
||||||
phoneKeyMap.put("2", "abc");
|
|
||||||
phoneKeyMap.put("3", "def");
|
|
||||||
phoneKeyMap.put("4", "ghi");
|
|
||||||
phoneKeyMap.put("5", "jkl");
|
|
||||||
phoneKeyMap.put("6", "mno");
|
|
||||||
phoneKeyMap.put("7", "pqrs");
|
|
||||||
phoneKeyMap.put("8", "tuv");
|
|
||||||
phoneKeyMap.put("9", "wxyz");
|
|
||||||
|
|
||||||
List<String> retStatus = new ArrayList<>();
|
|
||||||
|
|
||||||
if (digits != null && digits.length() != 0) {
|
|
||||||
phoneRecursive(digits, retStatus, phoneKeyMap, "", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println(retStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* phoneRecursive
|
|
||||||
*
|
|
||||||
* @param digits
|
|
||||||
* @param retStatus
|
|
||||||
* @param phoneKeyMap
|
|
||||||
* @param comb
|
|
||||||
* @param index
|
|
||||||
*/
|
|
||||||
private void phoneRecursive(String digits, List<String> retStatus, HashMap<String, String> phoneKeyMap, String comb, int index) {
|
|
||||||
if (index == digits.length()) {
|
|
||||||
retStatus.add(comb);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char pos = digits.charAt(index);
|
|
||||||
for (char c : ((String) phoneKeyMap.get(String.valueOf(pos))).toCharArray()) {
|
|
||||||
phoneRecursive(digits, retStatus, phoneKeyMap, comb + c, index + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
package com.ossez.codebank.algorithm.tests.lintcode;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 433
|
|
||||||
* <ul>
|
|
||||||
* <li>@see <a href=
|
|
||||||
* "https://www.cwiki.us/display/ITCLASSIFICATION/Number+of+Islands">https://www.cwiki.us/display/ITCLASSIFICATION/Number+of+Islands</a>
|
|
||||||
* <li>@see<a href="https://www.lintcode.com/problem/number-of-islands/">https://www.lintcode.com/problem/number-of-islands/</a>
|
|
||||||
* </ul>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class LintCode0433NumIslandsTest {
|
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(LintCode0433NumIslandsTest.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMain() {
|
|
||||||
logger.debug("BEGIN");
|
|
||||||
// INIT GRID
|
|
||||||
boolean[][] grid = { { true, true, false, false, false }, { false, true, false, false, true }, { false, false, false, true, true },
|
|
||||||
{ false, false, false, false, false }, { false, false, false, false, true }
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// NULL CHECK
|
|
||||||
if (grid.length == 0 || grid[0].length == 0) {
|
|
||||||
System.out.println("NULL");
|
|
||||||
// return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET SIZE
|
|
||||||
int n = grid.length;
|
|
||||||
int m = grid[0].length;
|
|
||||||
|
|
||||||
// ARRAY FOR VISITED LOG
|
|
||||||
boolean[][] visited = new boolean[n][m];
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
// LOOP FOR GRID
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
for (int j = 0; j < m; j++) {
|
|
||||||
if (grid[i][j] && !visited[i][j]) {
|
|
||||||
numIslandsDFS(grid, visited, i, j);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println(count);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param grid
|
|
||||||
* @param visited
|
|
||||||
* @param x
|
|
||||||
* @param y
|
|
||||||
*/
|
|
||||||
public void numIslandsDFS(boolean[][] grid, boolean[][] visited, int x, int y) {
|
|
||||||
if (x < 0 || x >= grid.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y < 0 || y >= grid[0].length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grid[x][y] != true || visited[x][y]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
visited[x][y] = true;
|
|
||||||
|
|
||||||
// Recursive call
|
|
||||||
numIslandsDFS(grid, visited, x - 1, y);
|
|
||||||
numIslandsDFS(grid, visited, x + 1, y);
|
|
||||||
numIslandsDFS(grid, visited, x, y - 1);
|
|
||||||
numIslandsDFS(grid, visited, x, y + 1);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package com.ossez.codebank.algorithm.tests.lintcode;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 1480
|
|
||||||
* <ul>
|
|
||||||
* <li>@see
|
|
||||||
* <a href= "https://www.cwiki.us/display/ITCLASSIFICATION/Dot+Product">https://www.cwiki.us/display/ITCLASSIFICATION/Dot+Product</a>
|
|
||||||
* <li>@see<a href= "https://www.lintcode.com/problem/dot-product/">https://www.lintcode.com/problem/dot-product/</a>
|
|
||||||
* </ul>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class LintCode1480DotProductTest {
|
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(LintCode1480DotProductTest.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMain() {
|
|
||||||
logger.debug("BEGIN");
|
|
||||||
int t = 87;
|
|
||||||
int[] dur = { 20, 25, 19, 37 };
|
|
||||||
// Write your code here
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
19
toolkits/.idea/compiler.xml
generated
19
toolkits/.idea/compiler.xml
generated
@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerConfiguration">
|
|
||||||
<annotationProcessing>
|
|
||||||
<profile name="Maven default annotation processors profile" enabled="true">
|
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
|
||||||
<outputRelativeToContentRoot value="true" />
|
|
||||||
<module name="codebank" />
|
|
||||||
<module name="discourse" />
|
|
||||||
</profile>
|
|
||||||
</annotationProcessing>
|
|
||||||
<bytecodeTargetLevel>
|
|
||||||
<module name="codebank" target="11" />
|
|
||||||
<module name="discourse" target="11" />
|
|
||||||
<module name="toolkits" target="11" />
|
|
||||||
</bytecodeTargetLevel>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
7
toolkits/.idea/encodings.xml
generated
7
toolkits/.idea/encodings.xml
generated
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding">
|
|
||||||
<file url="file://$PROJECT_DIR$/codebank/src/main/java" charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/discourse/src/main/java" charset="UTF-8" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
20
toolkits/.idea/jarRepositories.xml
generated
20
toolkits/.idea/jarRepositories.xml
generated
@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="central" />
|
|
||||||
<option name="name" value="Central Repository" />
|
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="central" />
|
|
||||||
<option name="name" value="Maven Central repository" />
|
|
||||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="jboss.community" />
|
|
||||||
<option name="name" value="JBoss Community repository" />
|
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
|
||||||
</remote-repository>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
6
toolkits/.idea/vcs.xml
generated
6
toolkits/.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.codebank.interview;
|
package com.ossez.toolkits.codebank.common.interview;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.codebank.interview;
|
package com.ossez.toolkits.codebank.common.interview;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.codebank.interview;
|
package com.ossez.toolkits.codebank.common.interview;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
@ -1,55 +1,57 @@
|
|||||||
package com.ossez.codebank.algorithml.utils;
|
package com.ossez.toolkits.codebank.common.utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.ossez.toolkits.codebank.common.model.TreeNode;
|
||||||
|
|
||||||
import com.ossez.codebank.algorithm.models.TreeNode;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
/**
|
||||||
*
|
*
|
||||||
*/
|
* @author YuCheng
|
||||||
public class TreeUtils {
|
*
|
||||||
|
*/
|
||||||
public static TreeNode initTree(String data) {
|
public class TreeUtils {
|
||||||
// NULL CHECK
|
|
||||||
if (data.equals("{}")) {
|
public static TreeNode initTree(String data) {
|
||||||
return null;
|
// NULL CHECK
|
||||||
}
|
if (data.equals("{}")) {
|
||||||
|
return null;
|
||||||
ArrayList<TreeNode> treeList = new ArrayList<TreeNode>();
|
}
|
||||||
|
|
||||||
data = data.replace("{", "");
|
ArrayList<TreeNode> treeList = new ArrayList<TreeNode>();
|
||||||
data = data.replace("}", "");
|
|
||||||
String[] vals = data.split(",");
|
data = data.replace("{", "");
|
||||||
|
data = data.replace("}", "");
|
||||||
// INSERT ROOT
|
String[] vals = data.split(",");
|
||||||
TreeNode root = new TreeNode(Integer.parseInt(vals[0]));
|
|
||||||
treeList.add(root);
|
// INSERT ROOT
|
||||||
|
TreeNode root = new TreeNode(Integer.parseInt(vals[0]));
|
||||||
int index = 0;
|
treeList.add(root);
|
||||||
boolean isLeftChild = true;
|
|
||||||
for (int i = 1; i < vals.length; i++) {
|
int index = 0;
|
||||||
if (!vals[i].equals("#")) {
|
boolean isLeftChild = true;
|
||||||
TreeNode node = new TreeNode(Integer.parseInt(vals[i]));
|
for (int i = 1; i < vals.length; i++) {
|
||||||
if (isLeftChild) {
|
if (!vals[i].equals("#")) {
|
||||||
treeList.get(index).left = node;
|
TreeNode node = new TreeNode(Integer.parseInt(vals[i]));
|
||||||
} else {
|
if (isLeftChild) {
|
||||||
treeList.get(index).right = node;
|
treeList.get(index).left = node;
|
||||||
}
|
} else {
|
||||||
treeList.add(node);
|
treeList.get(index).right = node;
|
||||||
}
|
}
|
||||||
|
treeList.add(node);
|
||||||
// LEVEL
|
}
|
||||||
if (!isLeftChild) {
|
|
||||||
index++;
|
// LEVEL
|
||||||
}
|
if (!isLeftChild) {
|
||||||
|
index++;
|
||||||
// MOVE TO RIGHT OR NEXT LEVEL
|
}
|
||||||
isLeftChild = !isLeftChild;
|
|
||||||
}
|
// MOVE TO RIGHT OR NEXT LEVEL
|
||||||
|
isLeftChild = !isLeftChild;
|
||||||
return root;
|
}
|
||||||
|
|
||||||
}
|
return root;
|
||||||
}
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,36 +1,36 @@
|
|||||||
package com.ossez.codebank.algorithm.tests;
|
package com.ossez.toolkits.codebank.tests;
|
||||||
|
|
||||||
import org.apache.commons.math3.util.FastMath;
|
import org.apache.commons.math3.util.FastMath;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author YuCheng
|
* @author YuCheng
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BitOperationTest {
|
public class BitOperationTest {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(BitOperationTest.class);
|
private final static Logger logger = LoggerFactory.getLogger(BitOperationTest.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 35 https://www.lintcode.com/problem/reverse-linked-list/description
|
* 35 https://www.lintcode.com/problem/reverse-linked-list/description
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testInt2Bit() {
|
public void testInt2Bit() {
|
||||||
logger.debug("BEGIN");
|
logger.debug("BEGIN");
|
||||||
System.out.println(Integer.toBinaryString(5));
|
System.out.println(Integer.toBinaryString(5));
|
||||||
System.out.println(Integer.toBinaryString(2));
|
System.out.println(Integer.toBinaryString(2));
|
||||||
|
|
||||||
System.out.println(Integer.toBinaryString(2 << 2));
|
System.out.println(Integer.toBinaryString(2 << 2));
|
||||||
|
|
||||||
System.out.println(Integer.parseInt(Integer.toBinaryString(2 << 2), 2));
|
System.out.println(Integer.parseInt(Integer.toBinaryString(2 << 2), 2));
|
||||||
|
|
||||||
System.out.println(5 / 3);
|
System.out.println(5 / 3);
|
||||||
System.out.println(5 % 3);
|
System.out.println(5 % 3);
|
||||||
FastMath.pow(2, 3);
|
FastMath.pow(2, 3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.ossez.toolkits.codebank.tests;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.TestInstance;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object of VariableOssez
|
||||||
|
*
|
||||||
|
* @author YuCheng
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class OssezVariable {
|
||||||
|
int s1, s2;
|
||||||
|
static int s3;
|
||||||
|
|
||||||
|
OssezVariable(int x, int y, int z) {
|
||||||
|
s1 = x;
|
||||||
|
s2 = y;
|
||||||
|
s3 = z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author YuCheng Hu
|
||||||
|
*/
|
||||||
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||||
|
public class DataStructureTest{
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(DataStructureTest.class);
|
||||||
|
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do RetsServerConnection Test
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testArrayDataStructure() {
|
||||||
|
|
||||||
|
int[] intArraySize = new int[3];
|
||||||
|
Integer intArrayW[] = new Integer[3];
|
||||||
|
logger.debug("Array Size - [{}]", intArraySize.length);
|
||||||
|
logger.debug("Array Size - [{}]", intArrayW.length);
|
||||||
|
|
||||||
|
int[] intArrayValue = {1,2,3};
|
||||||
|
String[] strArray = {"COM","OSSEZ","US"};
|
||||||
|
logger.debug("Array Size - [{}]", intArrayValue.length);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,23 +1,17 @@
|
|||||||
package com.ossez.lang.tutorial.tests;
|
package com.ossez.toolkits.codebank.tests;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.management.ListenerNotFoundException;
|
import com.ossez.toolkits.codebank.common.model.ListNode;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.ossez.lang.tutorial.models.ListNode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
@ -1,69 +1,69 @@
|
|||||||
package com.ossez.codebank.algorithm.tests;
|
package com.ossez.toolkits.codebank.tests;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Eager Singleton
|
* Eager Singleton
|
||||||
*
|
*
|
||||||
* @author YuCheng
|
* @author YuCheng
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class EagerSingleton {
|
class EagerSingleton {
|
||||||
private static final EagerSingleton INSTANCE = new EagerSingleton();
|
private static final EagerSingleton INSTANCE = new EagerSingleton();
|
||||||
|
|
||||||
// Private constructor suppresses
|
// Private constructor suppresses
|
||||||
private EagerSingleton() {
|
private EagerSingleton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// default public constructor
|
// default public constructor
|
||||||
public static EagerSingleton getInstance() {
|
public static EagerSingleton getInstance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lazy Singleton
|
* Lazy Singleton
|
||||||
*
|
*
|
||||||
* @author YuCheng
|
* @author YuCheng
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class LazySingleton {
|
class LazySingleton {
|
||||||
private static volatile LazySingleton INSTANCE = null;
|
private static volatile LazySingleton INSTANCE = null;
|
||||||
|
|
||||||
// Private constructor suppresses
|
// Private constructor suppresses
|
||||||
// default LazySingleton constructor
|
// default LazySingleton constructor
|
||||||
private LazySingleton() {
|
private LazySingleton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// thread safe and performance promote
|
// thread safe and performance promote
|
||||||
public static LazySingleton getInstance() {
|
public static LazySingleton getInstance() {
|
||||||
if (INSTANCE == null) {
|
if (INSTANCE == null) {
|
||||||
synchronized (LazySingleton.class) {
|
synchronized (LazySingleton.class) {
|
||||||
// when more than two threads run into the first null check same time, to avoid instanced more than one time, it needs to be
|
// when more than two threads run into the first null check same time, to avoid instanced more than one time, it needs to be
|
||||||
// checked again.
|
// checked again.
|
||||||
if (INSTANCE == null) {
|
if (INSTANCE == null) {
|
||||||
INSTANCE = new LazySingleton();
|
INSTANCE = new LazySingleton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author YuCheng
|
* @author YuCheng
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SingletonTest {
|
public class SingletonTest {
|
||||||
private final static Logger logger = LoggerFactory.getLogger(SingletonTest.class);
|
private final static Logger logger = LoggerFactory.getLogger(SingletonTest.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingleton() {
|
public void testSingleton() {
|
||||||
logger.debug("TEST Singleton");
|
logger.debug("TEST Singleton");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,85 +1,86 @@
|
|||||||
package com.ossez.codebank.algorithm.tests;
|
package com.ossez.toolkits.codebank.tests;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Test;
|
import com.ossez.toolkits.codebank.common.model.TreeNode;
|
||||||
import org.slf4j.Logger;
|
import com.ossez.toolkits.codebank.common.utils.TreeUtils;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
import com.ossez.codebank.algorithm.models.TreeNode;
|
import org.slf4j.LoggerFactory;
|
||||||
import com.ossez.codebank.algorithml.utils.TreeUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author YuCheng
|
*
|
||||||
*
|
* @author YuCheng
|
||||||
*/
|
*
|
||||||
public class TreeTest {
|
*/
|
||||||
private final static Logger logger = LoggerFactory.getLogger(TreeTest.class);
|
public class TreeTest {
|
||||||
private static List<Integer> loopList = new ArrayList<Integer>();
|
private final static Logger logger = LoggerFactory.getLogger(TreeTest.class);
|
||||||
|
private static List<Integer> loopList = new ArrayList<Integer>();
|
||||||
@Test
|
|
||||||
public void testMain() {
|
@Test
|
||||||
logger.debug("TREE TEST");
|
public void testMain() {
|
||||||
String data = "{1,2,3,4,5,#,6,#,#,7,8,#,#}";
|
logger.debug("TREE TEST");
|
||||||
TreeNode treeNode = TreeUtils.initTree(data);
|
String data = "{1,2,3,4,5,#,6,#,#,7,8,#,#}";
|
||||||
|
TreeNode treeNode = TreeUtils.initTree(data);
|
||||||
// PRE
|
|
||||||
loopList = new ArrayList<Integer>();
|
// PRE
|
||||||
preOrderTraverselRecursion(treeNode);
|
loopList = new ArrayList<Integer>();
|
||||||
System.out.println(loopList);
|
preOrderTraverselRecursion(treeNode);
|
||||||
|
System.out.println(loopList);
|
||||||
// IN
|
|
||||||
loopList = new ArrayList<Integer>();
|
// IN
|
||||||
inOrderTraverselRecursion(treeNode);
|
loopList = new ArrayList<Integer>();
|
||||||
System.out.println(loopList);
|
inOrderTraverselRecursion(treeNode);
|
||||||
|
System.out.println(loopList);
|
||||||
// POST
|
|
||||||
loopList = new ArrayList<Integer>();
|
// POST
|
||||||
postOrderTraversalRecursion(treeNode);
|
loopList = new ArrayList<Integer>();
|
||||||
System.out.println(loopList);
|
postOrderTraversalRecursion(treeNode);
|
||||||
}
|
System.out.println(loopList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @param root
|
*
|
||||||
*/
|
* @param root
|
||||||
public void preOrderTraverselRecursion(TreeNode root) {
|
*/
|
||||||
if (root != null) {
|
public void preOrderTraverselRecursion(TreeNode root) {
|
||||||
loopList.add(root.val);
|
if (root != null) {
|
||||||
preOrderTraverselRecursion(root.left);
|
loopList.add(root.val);
|
||||||
preOrderTraverselRecursion(root.right);
|
preOrderTraverselRecursion(root.left);
|
||||||
}
|
preOrderTraverselRecursion(root.right);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @param root
|
*
|
||||||
*/
|
* @param root
|
||||||
public void inOrderTraverselRecursion(TreeNode root) {
|
*/
|
||||||
if (root != null) {
|
public void inOrderTraverselRecursion(TreeNode root) {
|
||||||
inOrderTraverselRecursion(root.left);
|
if (root != null) {
|
||||||
loopList.add(root.val);
|
inOrderTraverselRecursion(root.left);
|
||||||
inOrderTraverselRecursion(root.right);
|
loopList.add(root.val);
|
||||||
}
|
inOrderTraverselRecursion(root.right);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @param root
|
*
|
||||||
*/
|
* @param root
|
||||||
public void postOrderTraversalRecursion(TreeNode root) {
|
*/
|
||||||
if (root != null) {
|
public void postOrderTraversalRecursion(TreeNode root) {
|
||||||
postOrderTraversalRecursion(root.left);
|
if (root != null) {
|
||||||
postOrderTraversalRecursion(root.right);
|
postOrderTraversalRecursion(root.left);
|
||||||
loopList.add(root.val);
|
postOrderTraversalRecursion(root.right);
|
||||||
}
|
loopList.add(root.val);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
@ -54,7 +54,8 @@ public class VariableTest extends TestCase {
|
|||||||
public void testStaticVariableChange() {
|
public void testStaticVariableChange() {
|
||||||
|
|
||||||
OssezVariable objA = new OssezVariable(1, 2, 3);
|
OssezVariable objA = new OssezVariable(1, 2, 3);
|
||||||
logger.debug("s1/s2/s3 - [{}]/[{}]/[{}]", objA.s1, objA.s2, OssezVariable.s3);
|
logger.debug("s1/s2/s3 - [{}]", Math.round(10.55));
|
||||||
|
|
||||||
|
|
||||||
OssezVariable objB = new OssezVariable(4, 5, 6);
|
OssezVariable objB = new OssezVariable(4, 5, 6);
|
||||||
logger.debug("s1/s2/s3 - [{}]/[{}]/[{}]", objA.s1, objA.s2, OssezVariable.s3);
|
logger.debug("s1/s2/s3 - [{}]/[{}]/[{}]", objA.s1, objA.s2, OssezVariable.s3);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.ossez.codebank.interview.tests;
|
package com.ossez.toolkits.codebank.tests.interview;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
@ -1,64 +1,65 @@
|
|||||||
package com.ossez.codebank.interview.tests;
|
package com.ossez.toolkits.codebank.tests.interview;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Assert;
|
||||||
import org.slf4j.Logger;
|
import org.junit.Test;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import com.ossez.codebank.interview.KayakCountUpDown;
|
|
||||||
import com.ossez.codebank.interview.KayakRobotMovement;
|
import com.ossez.toolkits.codebank.common.interview.KayakCountUpDown;
|
||||||
|
import com.ossez.toolkits.codebank.common.interview.KayakRobotMovement;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author YuCheng
|
*
|
||||||
*
|
* @author YuCheng
|
||||||
*/
|
*
|
||||||
public class KayakTest {
|
*/
|
||||||
|
public class KayakTest {
|
||||||
private final static Logger logger = LoggerFactory.getLogger(KayakTest.class);
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(KayakTest.class);
|
||||||
/**
|
|
||||||
* https://www.cwiki.us/display/ITCLASSIFICATION/Robot+Movement
|
/**
|
||||||
*
|
* https://www.cwiki.us/display/ITCLASSIFICATION/Robot+Movement
|
||||||
* testGetCoordinates
|
*
|
||||||
*
|
* testGetCoordinates
|
||||||
*/
|
*
|
||||||
@Test
|
*/
|
||||||
public void testGetCoordinates() {
|
@Test
|
||||||
logger.debug("TEST Get Coordinat ");
|
public void testGetCoordinates() {
|
||||||
logger.debug("LFFF - [{}]", KayakRobotMovement.getCoordinates("FF"));
|
logger.debug("TEST Get Coordinat ");
|
||||||
logger.debug("LFFFRFFFRRFFF - [{}]", KayakRobotMovement.getCoordinates("LFFFRFFFRRFFF"));
|
logger.debug("LFFF - [{}]", KayakRobotMovement.getCoordinates("FF"));
|
||||||
|
logger.debug("LFFFRFFFRRFFF - [{}]", KayakRobotMovement.getCoordinates("LFFFRFFFRRFFF"));
|
||||||
assertEquals(KayakRobotMovement.getCoordinates("FF"), "0,2");
|
|
||||||
assertEquals(KayakRobotMovement.getCoordinates("LFFFRFFFRRFFF"), "-3,0");
|
Assert.assertEquals(KayakRobotMovement.getCoordinates("FF"), "0,2");
|
||||||
|
Assert.assertEquals(KayakRobotMovement.getCoordinates("LFFFRFFFRRFFF"), "-3,0");
|
||||||
}
|
|
||||||
|
}
|
||||||
/**
|
|
||||||
* https://www.cwiki.us/display/ITCLASSIFICATION/Count+Up+Down
|
/**
|
||||||
*
|
* https://www.cwiki.us/display/ITCLASSIFICATION/Count+Up+Down
|
||||||
* CountUpDown
|
*
|
||||||
*/
|
* CountUpDown
|
||||||
@Test
|
*/
|
||||||
public void testCountUpDown() {
|
@Test
|
||||||
logger.debug("TEST Count Up and Down ");
|
public void testCountUpDown() {
|
||||||
|
logger.debug("TEST Count Up and Down ");
|
||||||
// 2 -5
|
|
||||||
logger.debug("[2 -> 5]");
|
// 2 -5
|
||||||
logger.debug("UP - {}", new KayakCountUpDown().countUp(2, 5));
|
logger.debug("[2 -> 5]");
|
||||||
logger.debug("UP & DOWN - {}", new KayakCountUpDown().countUpDown(2, 5));
|
logger.debug("UP - {}", new KayakCountUpDown().countUp(2, 5));
|
||||||
|
logger.debug("UP & DOWN - {}", new KayakCountUpDown().countUpDown(2, 5));
|
||||||
// 0 - 5
|
|
||||||
logger.debug("[0 -> 5]");
|
// 0 - 5
|
||||||
logger.debug("UP - {}", new KayakCountUpDown().countUp(0, 5));
|
logger.debug("[0 -> 5]");
|
||||||
logger.debug("UP & DOWN - {}", new KayakCountUpDown().countUpDown(0, 5));
|
logger.debug("UP - {}", new KayakCountUpDown().countUp(0, 5));
|
||||||
|
logger.debug("UP & DOWN - {}", new KayakCountUpDown().countUpDown(0, 5));
|
||||||
// -1 - 5
|
|
||||||
logger.debug("[-1 -> 5]");
|
// -1 - 5
|
||||||
logger.debug("UP - {}", new KayakCountUpDown().countUp(-1, 5));
|
logger.debug("[-1 -> 5]");
|
||||||
logger.debug("UP & DOWN - {}", new KayakCountUpDown().countUpDown(-1, 5));
|
logger.debug("UP - {}", new KayakCountUpDown().countUp(-1, 5));
|
||||||
|
logger.debug("UP & DOWN - {}", new KayakCountUpDown().countUpDown(-1, 5));
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.codebank.interview.tests.others;
|
package com.ossez.toolkits.codebank.tests.interview;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.codebank.interview.tests;
|
package com.ossez.toolkits.codebank.tests.interview;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
@ -1,12 +1,9 @@
|
|||||||
package com.ossez.codebank.interview.tests.others;
|
package com.ossez.toolkits.codebank.tests.interview;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For Minimum Coins
|
* For Minimum Coins
|
||||||
*
|
*
|
@ -1,83 +1,83 @@
|
|||||||
package com.ossez.codebank.interview.tests;
|
package com.ossez.toolkits.codebank.tests.interview;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PillPack
|
* PillPack
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* https://www.cwiki.us/display/ITCLASSIFICATION/Flatten+Nested+Arrays
|
* https://www.cwiki.us/display/ITCLASSIFICATION/Flatten+Nested+Arrays
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author YuCheng
|
* @author YuCheng
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PillPackTest {
|
public class PillPackTest {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(PillPackTest.class);
|
private final static Logger logger = LoggerFactory.getLogger(PillPackTest.class);
|
||||||
|
|
||||||
List<Integer> returnList = new ArrayList<Integer>();
|
List<Integer> returnList = new ArrayList<Integer>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://www.cwiki.us/display/ITCLASSIFICATION/Flatten+Nested+Arrays
|
* https://www.cwiki.us/display/ITCLASSIFICATION/Flatten+Nested+Arrays
|
||||||
*
|
*
|
||||||
* FlattenNestedArrays
|
* FlattenNestedArrays
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFlattenNestedArrays() {
|
public void testFlattenNestedArrays() {
|
||||||
logger.debug("Test FlattenNestedArrays");
|
logger.debug("Test FlattenNestedArrays");
|
||||||
|
|
||||||
Object[] array = { 1, 2, new Object[] { 3, 4, new Object[] { 5, new Object[] { new Object[] { 6 } } }, 7 }, 8, 9, 10 };
|
Object[] array = { 1, 2, new Object[] { 3, 4, new Object[] { 5, new Object[] { new Object[] { 6 } } }, 7 }, 8, 9, 10 };
|
||||||
logger.debug("LOOP: {} - > {}", Arrays.deepToString(array), Arrays.toString(loopFlatten(array)));
|
logger.debug("LOOP: {} - > {}", Arrays.deepToString(array), Arrays.toString(loopFlatten(array)));
|
||||||
|
|
||||||
logger.debug("Java 8: {} - > {}", Arrays.deepToString(array), Arrays.toString(java8Flatten(array).toArray()));
|
logger.debug("Java 8: {} - > {}", Arrays.deepToString(array), Arrays.toString(java8Flatten(array).toArray()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loop And Recursive
|
* Loop And Recursive
|
||||||
*
|
*
|
||||||
* @param inputArray
|
* @param inputArray
|
||||||
* @return
|
* @return
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
*/
|
*/
|
||||||
private static Integer[] loopFlatten(Object[] inputArray) throws IllegalArgumentException {
|
private static Integer[] loopFlatten(Object[] inputArray) throws IllegalArgumentException {
|
||||||
// NULL CHECK
|
// NULL CHECK
|
||||||
if (inputArray == null)
|
if (inputArray == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List<Integer> flatList = new ArrayList<Integer>();
|
List<Integer> flatList = new ArrayList<Integer>();
|
||||||
|
|
||||||
for (Object element : inputArray) {
|
for (Object element : inputArray) {
|
||||||
if (element instanceof Integer) {
|
if (element instanceof Integer) {
|
||||||
flatList.add((Integer) element);
|
flatList.add((Integer) element);
|
||||||
} else if (element instanceof Object[]) {
|
} else if (element instanceof Object[]) {
|
||||||
// Recursive
|
// Recursive
|
||||||
flatList.addAll(Arrays.asList(loopFlatten((Object[]) element)));
|
flatList.addAll(Arrays.asList(loopFlatten((Object[]) element)));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Input must be an array of Integers or nested arrays of Integers");
|
throw new IllegalArgumentException("Input must be an array of Integers or nested arrays of Integers");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return flatList.toArray(new Integer[flatList.size()]);
|
return flatList.toArray(new Integer[flatList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Java 8 Stream to Flatten array.
|
* Java 8 Stream to Flatten array.
|
||||||
*
|
*
|
||||||
* @param array
|
* @param array
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static Stream<Object> java8Flatten(Object[] array) {
|
private static Stream<Object> java8Flatten(Object[] array) {
|
||||||
// int[] flatInt = java8Flatten(array).mapToInt(Integer.class::cast).toArray();
|
// int[] flatInt = java8Flatten(array).mapToInt(Integer.class::cast).toArray();
|
||||||
return Arrays.stream(array).flatMap(o -> o instanceof Object[] ? java8Flatten((Object[]) o) : Stream.of(o));
|
return Arrays.stream(array).flatMap(o -> o instanceof Object[] ? java8Flatten((Object[]) o) : Stream.of(o));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.codebank.interview.tests;
|
package com.ossez.toolkits.codebank.tests.interview;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.codebank.interview.tests;
|
package com.ossez.toolkits.codebank.tests.interview;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
@ -7,10 +7,11 @@
|
|||||||
</Appenders>
|
</Appenders>
|
||||||
<Loggers>
|
<Loggers>
|
||||||
<Logger name="com.ossez" level="trace">
|
<Logger name="com.ossez" level="trace">
|
||||||
<AppenderRef ref="Console"/>
|
<AppenderRef ref="Console" />
|
||||||
</Logger>
|
</Logger>
|
||||||
<Root level="error">
|
|
||||||
<AppenderRef ref="Console"/>
|
<Root level="all">
|
||||||
|
|
||||||
</Root>
|
</Root>
|
||||||
</Loggers>
|
</Loggers>
|
||||||
</Configuration>
|
</Configuration>
|
@ -52,6 +52,14 @@
|
|||||||
<target>${java.version}</target>
|
<target>${java.version}</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>11</source>
|
||||||
|
<target>11</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user