FastPrepFind All Anagram Starting Positions
Problems/Find All Anagram Starting Positions

Find All Anagram Starting Positions

Intuit logoIntuit● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Intuit full-time online assessment. The report names the well-known Find All Anagrams problem and says there was one question in 60 minutes.

The report does not repeat the full statement. This version uses the named task's lowercase-letter rules and returns matching zero-based positions in ascending order.

Our version is about 95% the same as the named exercise.

Given strings s and p, find every starting position in s where a contiguous substring is an anagram of p. An anagram contains exactly the same letters with the same counts, possibly in a different order.

Return zero-based starting indices in ascending order. Matches may overlap. If p is longer than s or no match exists, return an empty array.

Function

findAnagrams(s: String, p: String) → List<Integer>

Examples

Example 1

s = "cbaebabacd"p = "abc"return = [0,6]

The length-three substrings starting at 0 and 6 are cba and bac. Each contains one a, one b, and one c. No other length-three substring has those counts.

Example 2

s = "abab"p = "ab"return = [0,1,2]

The three length-two substrings are ab, ba, and ab. They all match, including the overlapping match starting at 1.

Constraints

  • 1 <= s.length <= 30000.
  • 1 <= p.length <= 30000.
  • Both strings contain only lowercase English letters a through z.

More Intuit Online Assessment questions

  • Employee Promotion OpportunitiesOA · Seen Oct 2026
  • Next Pascal Row CoefficientOA · Seen Oct 2026
  • Parse Router LogsOA · Seen Oct 2026
  • Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
  • Maximum Square-Free DivisorOA · Seen Oct 2026
  • Two Tribes from Taller-Person CountsOA · Seen Oct 2026
  • Shortest Path from an Encoded GraphOA · Seen Sep 2026
  • Oldest and Youngest EmployeesOA · Seen Sep 2026
  • Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
  • Submask Sum QueriesOA · Seen Sep 2026

Similar questions at other companies

  • Maximum Valid Substring FrequencyMicrosoft · OAMicrosoft interview questions
  • Perfect SubstringAXQ Capital · OA
  • Longest Distinct StringSuperhuman · OASuperhuman interview questions
  • Longest Substring Without Repeating CharactersAkuna Capital · OAAkuna Capital interview questions
  • Perfect SubstringsVisa · OAVisa interview questions
  • Vowel SubstringSnowflake · OASnowflake interview questions
  • Count Distinct Fixed-Length SubstringsAdobe · OAAdobe interview questions
  • Video ID Generation (Generic)TikTok · OATikTok interview questions
  • Unaligned DedupeRubrik · OARubrik interview questions
  • Get Max OccurrencesIBM · OAIBM interview questions

Interview reports that mention this question

  • Intuit OA: What It Tests (2026)

Intuit interview experiences

  • Intuit Software Engineering Intern - Full Stack OA Format
All Intuit interview questionsSee Intuit hiring insights
Saved
class Solution {
    public List<Integer> findAnagrams(String s, String p) {
        // Write your code here
    }
}
Checking account…