Skip to content

Commit d999aae

Browse files
authored
Merge branch 'master' into cleanUp_ArrayCombination
2 parents a991feb + 06927d3 commit d999aae

File tree

270 files changed

+3009
-2524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+3009
-2524
lines changed

.gitpod.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM gitpod/workspace-java-21:2024-05-15-13-36-34
1+
FROM gitpod/workspace-java-21:2024-07-02-14-18-47
22

33
ENV LLVM_SCRIPT="tmp_llvm.sh"
44

DIRECTORY.md

Lines changed: 20 additions & 13 deletions
Large diffs are not rendered by default.

checkstyle.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100
<!-- Checks for Javadoc comments. -->
101101
<!-- See https://checkstyle.org/checks/javadoc/index.html -->
102-
<!-- TODO <module name="InvalidJavadocPosition"/> -->
102+
<module name="InvalidJavadocPosition"/>
103103
<!-- TODO <module name="JavadocMethod"/> -->
104104
<!-- TODO <module name="JavadocType"/> -->
105105
<!-- TODO <module name="JavadocVariable"/> -->
@@ -110,13 +110,13 @@
110110
<!-- See https://checkstyle.org/checks/naming/index.html -->
111111
<module name="ConstantName"/>
112112
<module name="LocalFinalVariableName"/>
113-
<!-- TODO <module name="LocalVariableName"/> -->
114-
<!-- TODO <module name="MemberName"/> -->
115-
<!-- TODO <module name="MethodName"/> -->
113+
<module name="LocalVariableName"/>
114+
<module name="MemberName"/>
115+
<module name="MethodName"/>
116116
<module name="PackageName"/>
117-
<!-- TODO <module name="ParameterName"/> -->
117+
<module name="ParameterName"/>
118118
<module name="StaticVariableName"/>
119-
<!-- TODO <module name="TypeName"/> -->
119+
<module name="TypeName"/>
120120

121121
<!-- Checks for imports -->
122122
<!-- See https://checkstyle.org/checks/imports/index.html -->
@@ -139,11 +139,11 @@
139139
<module name="MethodParamPad"/>
140140
<!-- TODO <module name="NoWhitespaceAfter"/> -->
141141
<module name="NoWhitespaceBefore"/>
142-
<!-- TODO <module name="OperatorWrap"/> -->
143-
<!-- TODO <module name="ParenPad"/> -->
142+
<module name="OperatorWrap"/>
143+
<module name="ParenPad"/>
144144
<module name="TypecastParenPad"/>
145145
<module name="WhitespaceAfter"/>
146-
<!-- TODO <module name="WhitespaceAround"/> -->
146+
<module name="WhitespaceAround"/>
147147

148148
<!-- Modifier Checks -->
149149
<!-- See https://checkstyle.org/checks/modifier/index.html -->
@@ -152,10 +152,10 @@
152152

153153
<!-- Checks for blocks. You know, those {}'s -->
154154
<!-- See https://checkstyle.org/checks/blocks/index.html -->
155-
<!-- TODO <module name="AvoidNestedBlocks"/> -->
155+
<module name="AvoidNestedBlocks"/>
156156
<!-- TODO <module name="EmptyBlock"/> -->
157157
<!-- TODO <module name="LeftCurly"/> -->
158-
<!-- TODO <module name="NeedBraces"/> -->
158+
<module name="NeedBraces"/>
159159
<!-- TODO <module name="RightCurly"/> -->
160160

161161
<!-- Checks for common coding problems -->
@@ -166,7 +166,7 @@
166166
<module name="IllegalInstantiation"/>
167167
<module name="InnerAssignment"/>
168168
<!-- TODO <module name="MagicNumber"/> -->
169-
<!-- TODO <module name="MissingSwitchDefault"/> -->
169+
<module name="MissingSwitchDefault"/>
170170
<module name="MultipleVariableDeclarations"/>
171171
<module name="SimplifyBooleanExpression"/>
172172
<module name="SimplifyBooleanReturn"/>

pmd-exclude.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ com.thealgorithms.conversions.HexToOct=UselessParentheses
1010
com.thealgorithms.conversions.IntegerToRoman=UnnecessaryFullyQualifiedName
1111
com.thealgorithms.datastructures.crdt.LWWElementSet=UselessParentheses
1212
com.thealgorithms.datastructures.crdt.Pair=UnusedPrivateField
13-
com.thealgorithms.datastructures.graphs.A_Star=UselessParentheses
13+
com.thealgorithms.datastructures.graphs.AStar=UselessParentheses
1414
com.thealgorithms.datastructures.graphs.AdjacencyMatrixGraph=CollapsibleIfStatements,UnnecessaryFullyQualifiedName,UselessParentheses
1515
com.thealgorithms.datastructures.graphs.BipartiteGrapfDFS=CollapsibleIfStatements
1616
com.thealgorithms.datastructures.graphs.Kruskal=UselessParentheses
@@ -76,7 +76,6 @@ com.thealgorithms.searches.InterpolationSearch=UselessParentheses
7676
com.thealgorithms.searches.KMPSearch=UselessParentheses
7777
com.thealgorithms.searches.LinearSearchThread=EmptyCatchBlock
7878
com.thealgorithms.searches.RabinKarpAlgorithm=UselessParentheses
79-
com.thealgorithms.sorts.BubbleSortRecursion=UselessParentheses
8079
com.thealgorithms.sorts.CircleSort=EmptyControlStatement
8180
com.thealgorithms.sorts.CombSort=UselessParentheses
8281
com.thealgorithms.sorts.DutchNationalFlagSort=UselessParentheses

pom.xml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<maven.compiler.source>21</maven.compiler.source>
1414
<maven.compiler.target>21</maven.compiler.target>
15-
<assertj.version>3.25.3</assertj.version>
15+
<assertj.version>3.26.3</assertj.version>
1616
</properties>
1717

1818
<dependencyManagement>
1919
<dependencies>
2020
<dependency>
2121
<groupId>org.junit</groupId>
2222
<artifactId>junit-bom</artifactId>
23-
<version>5.10.2</version>
23+
<version>5.10.3</version>
2424
<type>pom</type>
2525
<scope>import</scope>
2626
</dependency>
@@ -31,7 +31,7 @@
3131
<dependency>
3232
<groupId>org.junit.jupiter</groupId>
3333
<artifactId>junit-jupiter</artifactId>
34-
<version>5.10.2</version>
34+
<version>5.10.3</version>
3535
<scope>test</scope>
3636
</dependency>
3737
<dependency>
@@ -44,7 +44,7 @@
4444
<dependency>
4545
<groupId>org.junit.jupiter</groupId>
4646
<artifactId>junit-jupiter-api</artifactId>
47-
<version>5.10.2</version>
47+
<version>5.10.3</version>
4848
<scope>test</scope>
4949
</dependency>
5050
<dependency>
@@ -55,15 +55,15 @@
5555
<dependency>
5656
<groupId>org.apache.commons</groupId>
5757
<artifactId>commons-collections4</artifactId>
58-
<version>4.5.0-M1</version>
58+
<version>4.5.0-M2</version>
5959
</dependency>
6060
</dependencies>
6161

6262
<build>
6363
<plugins>
6464
<plugin>
6565
<artifactId>maven-surefire-plugin</artifactId>
66-
<version>3.2.5</version>
66+
<version>3.3.0</version>
6767
<configuration>
6868
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
6969
</configuration>
@@ -79,7 +79,6 @@
7979
<arg>-Xlint:all</arg>
8080
<arg>-Xlint:-auxiliaryclass</arg>
8181
<arg>-Xlint:-rawtypes</arg>
82-
<arg>-Xlint:-try</arg>
8382
<arg>-Xlint:-unchecked</arg>
8483
<arg>-Xlint:-lossy-conversions</arg>
8584
<arg>-Werror</arg>
@@ -108,7 +107,7 @@
108107
<plugin>
109108
<groupId>org.apache.maven.plugins</groupId>
110109
<artifactId>maven-checkstyle-plugin</artifactId>
111-
<version>3.3.1</version>
110+
<version>3.4.0</version>
112111
<configuration>
113112
<configLocation>checkstyle.xml</configLocation>
114113
<consoleOutput>true</consoleOutput>
@@ -119,14 +118,14 @@
119118
<dependency>
120119
<groupId>com.puppycrawl.tools</groupId>
121120
<artifactId>checkstyle</artifactId>
122-
<version>10.16.0</version>
121+
<version>10.17.0</version>
123122
</dependency>
124123
</dependencies>
125124
</plugin>
126125
<plugin>
127126
<groupId>com.github.spotbugs</groupId>
128127
<artifactId>spotbugs-maven-plugin</artifactId>
129-
<version>4.8.5.0</version>
128+
<version>4.8.6.2</version>
130129
<configuration>
131130
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
132131
<includeTests>true</includeTests>
@@ -147,7 +146,7 @@
147146
<plugin>
148147
<groupId>org.apache.maven.plugins</groupId>
149148
<artifactId>maven-pmd-plugin</artifactId>
150-
<version>3.22.0</version>
149+
<version>3.23.0</version>
151150
<configuration>
152151
<printFailingErrors>true</printFailingErrors>
153152
<includeTests>true</includeTests>

spotbugs-exclude.xml

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<Match>
1818
<Bug pattern="DM_NEXTINT_VIA_NEXTDOUBLE" />
1919
</Match>
20-
<Match>
21-
<Bug pattern="NM_CLASS_NAMING_CONVENTION" />
22-
</Match>
2320
<Match>
2421
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC" />
2522
</Match>
@@ -44,9 +41,6 @@
4441
<Match>
4542
<Bug pattern="INT_BAD_REM_BY_1" />
4643
</Match>
47-
<Match>
48-
<Bug pattern="NM_METHOD_NAMING_CONVENTION" />
49-
</Match>
5044
<Match>
5145
<Bug pattern="ICAST_IDIV_CAST_TO_DOUBLE" />
5246
</Match>
@@ -65,27 +59,12 @@
6559
<Match>
6660
<Bug pattern="MS_EXPOSE_REP" />
6761
</Match>
68-
<Match>
69-
<Bug pattern="IM_BAD_CHECK_FOR_ODD" />
70-
</Match>
71-
<Match>
72-
<Bug pattern="WMI_WRONG_MAP_ITERATOR" />
73-
</Match>
7462
<Match>
7563
<Bug pattern="DM_BOXED_PRIMITIVE_FOR_PARSING" />
7664
</Match>
7765
<Match>
7866
<Bug pattern="UWF_UNWRITTEN_FIELD" />
7967
</Match>
80-
<Match>
81-
<Bug pattern="SS_SHOULD_BE_STATIC" />
82-
</Match>
83-
<Match>
84-
<Bug pattern="IT_NO_SUCH_ELEMENT" />
85-
</Match>
86-
<Match>
87-
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
88-
</Match>
8968
<Match>
9069
<Bug pattern="UWF_NULL_FIELD" />
9170
</Match>
@@ -107,9 +86,6 @@
10786
<Match>
10887
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
10988
</Match>
110-
<Match>
111-
<Bug pattern="RV_ABSOLUTE_VALUE_OF_HASHCODE" />
112-
</Match>
11389
<!-- fb-contrib -->
11490
<Match>
11591
<Bug pattern="OCP_OVERLY_CONCRETE_PARAMETER" />
@@ -132,33 +108,18 @@
132108
<Match>
133109
<Bug pattern="CLI_CONSTANT_LIST_INDEX" />
134110
</Match>
135-
<Match>
136-
<Bug pattern="BED_BOGUS_EXCEPTION_DECLARATION" />
137-
</Match>
138111
<Match>
139112
<Bug pattern="CNC_COLLECTION_NAMING_CONFUSION" />
140113
</Match>
141114
<Match>
142115
<Bug pattern="TR_TAIL_RECURSION" />
143116
</Match>
144-
<Match>
145-
<Bug pattern="LII_LIST_INDEXED_ITERATING" />
146-
</Match>
147117
<Match>
148118
<Bug pattern="USBR_UNNECESSARY_STORE_BEFORE_RETURN" />
149119
</Match>
150-
<Match>
151-
<Bug pattern="MAC_MANUAL_ARRAY_COPY" />
152-
</Match>
153-
<Match>
154-
<Bug pattern="SPP_USE_ISEMPTY" />
155-
</Match>
156120
<Match>
157121
<Bug pattern="BL_BURYING_LOGIC" />
158122
</Match>
159-
<Match>
160-
<Bug pattern="OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION" />
161-
</Match>
162123
<Match>
163124
<Bug pattern="PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" />
164125
</Match>
@@ -213,24 +174,12 @@
213174
<Match>
214175
<Bug pattern="ITU_INAPPROPRIATE_TOSTRING_USE" />
215176
</Match>
216-
<Match>
217-
<Bug pattern="DMC_DUBIOUS_MAP_COLLECTION" />
218-
</Match>
219177
<Match>
220178
<Bug pattern="SPP_PASSING_THIS_AS_PARM" />
221179
</Match>
222180
<Match>
223181
<Bug pattern="FCBL_FIELD_COULD_BE_LOCAL" />
224182
</Match>
225-
<Match>
226-
<Bug pattern="ENMI_EQUALS_ON_ENUM" />
227-
</Match>
228-
<Match>
229-
<Bug pattern="NAB_NEEDLESS_BOXING_PARSE" />
230-
</Match>
231-
<Match>
232-
<Bug pattern="IMC_IMMATURE_CLASS_VAR_NAME" />
233-
</Match>
234183
<Match>
235184
<Bug pattern="CFS_CONFUSING_FUNCTION_SEMANTICS" />
236185
</Match>
@@ -252,18 +201,12 @@
252201
<Match>
253202
<Bug pattern="IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID" />
254203
</Match>
255-
<Match>
256-
<Bug pattern="SUI_CONTAINS_BEFORE_ADD" />
257-
</Match>
258204
<Match>
259205
<Bug pattern="DRE_DECLARED_RUNTIME_EXCEPTION" />
260206
</Match>
261207
<Match>
262208
<Bug pattern="SLS_SUSPICIOUS_LOOP_SEARCH" />
263209
</Match>
264-
<Match>
265-
<Bug pattern="SPP_TOSTRING_ON_STRING" />
266-
</Match>
267210
<!-- find-sec-bugs -->
268211
<Match>
269212
<Bug pattern="PREDICTABLE_RANDOM" />

src/main/java/com/thealgorithms/backtracking/AllPathsFromSourceToTarget.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
/**
2-
* Author : Siddhant Swarup Mallick
3-
* Github : https://github.com/siddhant2002
4-
*/
5-
6-
/** Program description - To find all possible paths from source to destination*/
7-
8-
/**Wikipedia link -> https://en.wikipedia.org/wiki/Shortest_path_problem */
91
package com.thealgorithms.backtracking;
102

113
import java.util.ArrayList;
124
import java.util.List;
135

6+
/**
7+
* Program description - To find all possible paths from source to destination
8+
* <a href="https://en.wikipedia.org/wiki/Shortest_path_problem">Wikipedia</a>
9+
*
10+
* @author <a href="https://github.com/siddhant2002">Siddhant Swarup Mallick</a>
11+
*/
1412
public class AllPathsFromSourceToTarget {
1513

1614
// No. of vertices in graph

src/main/java/com/thealgorithms/backtracking/Combination.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public static <T> List<TreeSet<T>> combination(T[] arr, int n) {
4343
* @param <T> the type of elements in the array.
4444
*/
4545
private static <T> void backtracking(T[] arr, int index, TreeSet<T> currSet, List<TreeSet<T>> result) {
46-
if (index + length - currSet.size() > arr.length) return;
46+
if (index + length - currSet.size() > arr.length) {
47+
return;
48+
}
4749
if (length - 1 == currSet.size()) {
4850
for (int i = index; i < arr.length; i++) {
4951
currSet.add(arr[i]);

src/main/java/com/thealgorithms/backtracking/MColoring.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ static int possiblePaint(ArrayList<Node> nodes, int n, int m) {
5959
// If number of colors used exceeds m,
6060
// return 0
6161
maxColors = Math.max(maxColors, Math.max(nodes.get(top).color, nodes.get(it).color));
62-
if (maxColors > m) return 0;
62+
if (maxColors > m) {
63+
return 0;
64+
}
6365

6466
// If the adjacent node is not visited,
6567
// mark it visited and push it in queue

0 commit comments

Comments
 (0)