Skip to content

Commit 5596304

Browse files
committed
FindAllAnagramsInAString: adjust solution, add YT link
1 parent 57fa43f commit 5596304

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/by/andd3dfx/string/FindAllAnagramsInAString.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
* The substring with start index = 1 is "ba", which is an anagram of "ab".
2828
* The substring with start index = 2 is "ab", which is an anagram of "ab".
2929
* </pre>
30+
*
31+
* @see <a href="https://youtu.be/RiEtVGg_Lm8">Video solution</a>
3032
*/
3133
public class FindAllAnagramsInAString {
3234

@@ -35,9 +37,8 @@ public static List<Integer> findAnagrams(String s, String p) {
3537
var normalizedP = normalize(p);
3638

3739
Set<String> approvedStrings = new HashSet<>();
38-
approvedStrings.add(normalizedP);
3940
for (var start = 0; start <= s.length() - p.length(); start++) {
40-
String candidate = s.substring(start, start + p.length());
41+
var candidate = s.substring(start, start + p.length());
4142

4243
if (approvedStrings.contains(candidate) || normalizedP.equals(normalize(candidate))) {
4344
approvedStrings.add(candidate);

0 commit comments

Comments
 (0)