Skip to content

Commit 9a3e936

Browse files
committed
Words Concatenation - WIP
1 parent ca9828a commit 9a3e936

File tree

7 files changed

+457
-8
lines changed

7 files changed

+457
-8
lines changed

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"ms-vscode.vscode-typescript-tslint-plugin",
6464
"redhat.vscode-yaml",
6565
"VisualStudioExptTeam.vscodeintellicode",
66-
"DotJoshJohnson.xml"
66+
"DotJoshJohnson.xml",
67+
"shengchen.vscode-checkstyle"
6768
]
6869
}

.vscode/settings.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@
333333
"yusun",
334334
"zrzahid"
335335
],
336+
"editor.formatOnSave": true,
336337
"python.unitTest.unittestEnabled": false,
337338
"python.unitTest.unittestArgs": [
338339
"-v",
@@ -346,13 +347,14 @@
346347
"python.unitTest.nosetestsEnabled": false,
347348
"python.pythonPath": "C:\\Program Files\\Python37\\python.exe",
348349
"python.linting.pylintEnabled": true,
349-
"java.test.config": [
350-
{
351-
"name": "myConfig",
352-
"workingDirectory": "${workspaceFolder}"
353-
}
354-
],
350+
"java.test.config": [{
351+
"name": "myConfig",
352+
"workingDirectory": "${workspaceFolder}"
353+
}],
355354
"java.test.defaultConfig": "myConfig",
356355
"markdown.extension.print.onFileSave": false,
357-
"markdownShortcuts.bullets.marker": "-"
356+
"markdownShortcuts.bullets.marker": "-",
357+
"java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml",
358+
"java.format.settings.profile": "GoogleStyle",
359+
"java.checkstyle.configuration": "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml"
358360
}

eclipse-formatter.xml

Lines changed: 315 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package EducativeIo.GrokkingTheCodingInterview.Ch02_Pattern_SlidingWindow.PC4_WordsConcatenation.Java;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class Solution {
7+
public static void main(String[] args) {
8+
List<Integer> result = findWordConcatenation("catfoxcat", new String[] {"cat", "fox"});
9+
System.out.println(result);
10+
result = findWordConcatenation("catcatfoxfox", new String[] {"cat", "fox"});
11+
System.out.println(result);
12+
}
13+
14+
15+
public static List<Integer> findWordConcatenation(String str, String[] words) {
16+
List<Integer> resultIndices = new ArrayList<Integer>();
17+
// TODO: Write your code here
18+
return resultIndices;
19+
}
20+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package EducativeIo.GrokkingTheCodingInterview.Ch02_Pattern_SlidingWindow.PC4_WordsConcatenation.Java;
2+
3+
import static org.junit.jupiter.api.Assertions.*;
4+
import java.time.Duration;
5+
import org.junit.jupiter.api.Test;
6+
import org.junit.jupiter.api.AfterEach;
7+
import org.junit.jupiter.api.BeforeEach;
8+
9+
public class SolutionTest {
10+
11+
Solution solution;
12+
13+
@BeforeEach
14+
public void setUp() throws Exception {
15+
solution = new Solution();
16+
}
17+
18+
@AfterEach
19+
public void tearDown() throws Exception {
20+
solution = null;
21+
}
22+
23+
@Test
24+
public void MainFunction() {
25+
assertTimeout(Duration.ofMillis(500), () -> {
26+
String[] args = new String[0];
27+
assertAll(() -> Solution.main(args));
28+
});
29+
}
30+
31+
@Test
32+
public void TrivialCase1() {
33+
// input = ;
34+
assertTimeout(Duration.ofMillis(500), () -> {
35+
// expected = ;
36+
// actual = Solution.;
37+
// assertEquals(expected, actual);
38+
});
39+
}
40+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"type": "Coding",
3+
"name": "Words Concatenation",
4+
"origin": {
5+
"name": "Educative",
6+
"link": "https://www.educative.io/collection/page/5668639101419520/5671464854355968/4559641746866176"
7+
},
8+
"companies": [
9+
"",
10+
""
11+
],
12+
"categories": [
13+
{
14+
"name": "Courses",
15+
"children": [
16+
{
17+
"name": "Grokking the Coding Interview: Patterns for Coding Questions",
18+
"children": []
19+
}
20+
]
21+
},
22+
{
23+
"name": "Difficulty",
24+
"children": [
25+
{
26+
"name": "Hard",
27+
"children": []
28+
}
29+
]
30+
},
31+
{
32+
"name": "Pattern",
33+
"children": [
34+
{
35+
"name": "Sliding Window",
36+
"children": []
37+
}
38+
]
39+
}
40+
],
41+
"tags": [
42+
"Arrays"
43+
],
44+
"buckets": [
45+
"",
46+
""
47+
]
48+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Problem Definition
2+
3+
## Description
4+
5+
Given a string and a list of words, find all the starting indices of substrings in the given string that are a **concatenation of all the given words** exactly once **without any overlapping** of words. You can assume that all words are of the same length.
6+
7+
Example 1:
8+
9+
```text
10+
Input: String="catfoxcat", Words=["cat", "fox"]
11+
Output: [0, 3]
12+
Explanation: The two substring containing both the words are "catfox" & "foxcat".
13+
```
14+
15+
Example 2:
16+
17+
```text
18+
Input: String="catcatfoxfox", Words=["cat", "fox"]
19+
Output: [3]
20+
Explanation: The only substring containing both the words is "catfox".
21+
```
22+
23+
## Notes

0 commit comments

Comments
 (0)