DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
String

Find All Anagrams in String

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Find All Anagrams in String** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Sliding window + character frequency **Edge Cases to Consider:** - (1) p longer than s - (2) No anagrams - (3) All characters same

Examples

Example 1
Input: "cbaebabacd", "abc"
Output: [0,6]
Example 2
Input: "abab", "ab"
Output: [0,1,2]
Example 3
Input: "a", "a"
Output: [0]
Explanation: Single

Constraints

  • ▪1 <= s.length <= 10^4
  • ▪s consists of printable ASCII characters
  • ▪Solve with optimal space complexity

Watch Out For Edge Cases

  • ▪p longer than s
  • ▪No anagrams
  • ▪All characters same
Frequently Asked At
AmazonGoogleMicrosoftAdobe