package leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * https://leetcode.com/problems/find-all-anagrams-in-a-string/
 */
public class Problem438 {
    public List<Integer> findAnagrams(String s, String p) {
        List<Integer> result = new ArrayList<>();
        // TODO
        return result;
    }

    public static void main(String[] args) {
        Problem438 prob = new Problem438();
        System.out.println(prob.findAnagrams("cbaebabacd", "abc")); // [0, 6]
        System.out.println(prob.findAnagrams("abab", "ab")); // [0, 1, 2]
    }
}

@@ -40,16 +40,41 @@
 ayList;%0A
+import java.util.Arrays;%0A
 import j
@@ -88,16 +88,16 @@
 l.List;%0A
-
 %0A/**%0A * 
@@ -309,15 +309,423 @@
     
-// TODO
+char%5B%5D sortedP = p.toCharArray();%0A        Arrays.sort(sortedP);%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            if (i + p.length() %3E s.length()) %7B%0A                break;%0A            %7D%0A            char%5B%5D sortedSub = s.substring(i, i + p.length()).toCharArray();%0A            Arrays.sort(sortedSub);%0A            if (Arrays.equals(sortedP, sortedSub)) %7B%0A                result.add(i);%0A            %7D%0A        %7D
 %0A   

Update problem 438