Skip to content

Commit 31dc2eb

Browse files
committed
multimodule
1 parent 728ab1e commit 31dc2eb

File tree

72 files changed

+150
-33
lines changed

Some content is hidden

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

72 files changed

+150
-33
lines changed

.idea/encodings.xml

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 40 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data-structures/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.thealgorithm</groupId>
8+
<artifactId>TheAlgorithm</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<groupId>com.thealgorithm</groupId>
13+
<artifactId>data-structures</artifactId>
14+
15+
<properties>
16+
<maven.compiler.source>21</maven.compiler.source>
17+
<maven.compiler.target>21</maven.compiler.target>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
</properties>
20+
21+
</project>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.thealgorithm.miscelleneous;
2+
3+
import java.util.ArrayList;
4+
import java.util.HashSet;
5+
import java.util.List;
6+
import java.util.Set;
7+
8+
/**
9+
* @author: Subham Santra
10+
*/
11+
public class GenerateParenthesis {
12+
13+
public List<String> generate(int c1, int c2, int c3) {
14+
Set<String> result = new HashSet<>();
15+
generate(c1, 0, 0, c2, 0, 0, c3, 0, 0, result, new StringBuilder());
16+
return new ArrayList<>(result);
17+
}
18+
19+
private void generate(
20+
int c1,
21+
int o1,
22+
int e1,
23+
int c2,
24+
int o2,
25+
int e2,
26+
int c3,
27+
int o3,
28+
int e3,
29+
Set<String> result,
30+
StringBuilder comb) {
31+
32+
if (e1 > o1 || e2 > o2 || e3 > o3) {
33+
return;
34+
}
35+
36+
// if (o1 == c1 && o1 == e1 && o2 == c2 && o2 == e2 && o3 == c3 && o3 == e3) {
37+
if (o1 == c1 && o2 == c2 && o3 == c3) {
38+
// if (o1 == e1 && o2 == e2 && o3 == e3) {
39+
result.add(comb.toString());
40+
return;
41+
}
42+
43+
if (o1 < c1) {
44+
comb.append('(');
45+
generate(c1, o1 + 1, e1, c2, o2, e2, c3, o3, e3, result, comb);
46+
comb.deleteCharAt(comb.length() - 1);
47+
48+
comb.append(')');
49+
generate(c1, o1, e1 + 1, c2, o2, e2, c3, o3, e3, result, comb);
50+
comb.deleteCharAt(comb.length() - 1);
51+
}
52+
53+
if (o2 < c2) {
54+
comb.append('{');
55+
generate(c1, o1, e1, c2, o2 + 1, e2, c3, o3, e3, result, comb);
56+
comb.deleteCharAt(comb.length() - 1);
57+
58+
comb.append('}');
59+
generate(c1, o1, e1, c2, o2, e2 + 1, c3, o3, e3, result, comb);
60+
comb.deleteCharAt(comb.length() - 1);
61+
}
62+
63+
if (o3 < c3) {
64+
comb.append('[');
65+
generate(c1, o1, e1, c2, o2, e2, c3, o3 + 1, e3, result, comb);
66+
comb.deleteCharAt(comb.length() - 1);
67+
68+
comb.append(']');
69+
generate(c1, o1 + 1, e1, c2, o2, e2, c3, o3, e3 + 1, result, comb);
70+
comb.deleteCharAt(comb.length() - 1);
71+
}
72+
}
73+
74+
public static void main(String[] args) {
75+
System.out.println(new GenerateParenthesis().generate(2, 2, 2));
76+
}
77+
}

src/main/java/com/thealgorithm/dp/miscelleneous/LeetCode1155.java renamed to data-structures/src/main/java/com/thealgorithm/miscelleneous/LeetCode1155.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.thealgorithm.dp.miscelleneous;
1+
package com.thealgorithm.miscelleneous;
22

33
/**
44
* @see <a

src/main/java/com/thealgorithm/dp/miscelleneous/LeetCode1235.java renamed to data-structures/src/main/java/com/thealgorithm/miscelleneous/LeetCode1235.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.thealgorithm.dp.miscelleneous;
1+
package com.thealgorithm.miscelleneous;
22

33
import java.util.Arrays;
44

src/main/java/com/thealgorithm/dp/miscelleneous/LeetCode1335.java renamed to data-structures/src/main/java/com/thealgorithm/miscelleneous/LeetCode1335.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.thealgorithm.dp.miscelleneous;
1+
package com.thealgorithm.miscelleneous;
22

33
import java.util.Arrays;
44

src/main/java/com/thealgorithm/dp/miscelleneous/LeetCode446.java renamed to data-structures/src/main/java/com/thealgorithm/miscelleneous/LeetCode446.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.thealgorithm.dp.miscelleneous;
1+
package com.thealgorithm.miscelleneous;
22

33
import java.util.ArrayList;
44
import java.util.HashMap;

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
<groupId>com.thealgorithm</groupId>
88
<artifactId>TheAlgorithm</artifactId>
99
<version>1.0-SNAPSHOT</version>
10+
<packaging>pom</packaging>
11+
<modules>
12+
<module>data-structures</module>
13+
</modules>
1014

1115
<properties>
1216
<maven.compiler.source>21</maven.compiler.source>

0 commit comments

Comments
 (0)