FastPrepFind Repetitions
Problems/Find Repetitions

Find Repetitions

Pure Storage logoPure Storage● EasyINTERNOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given a short string short_s and a long string long_s. Return the largest integer k such that short_s repeated k times appears as one contiguous substring of long_s.

The copies in a repetition must be adjacent and non-overlapping. Return 0 if either string is empty or if short_s does not occur.

Function

findRepetitions(short_s: String, long_s: String) → int

Examples

Example 1

short_s = "AB"long_s = "ABBAC"return = 1

AB occurs once in ABBAC, so the maximum consecutive repetition count is 1.

Example 2

short_s = "AB"long_s = "ABCABCABAB"return = 2

AB starts at indices 0, 3, 6, and 8. Only the occurrences at indices 6 and 8 are adjacent, forming ABAB, so the answer is 2.

Constraints

  • 0 <= short_s.length < 10
  • 0 <= long_s.length < 1000000

More Pure Storage interview questions

  • One-Shot Callback Event DispatchONSITE INTERVIEW · Seen Dec 2026
  • Perfect AND Tree Leaf UpdatesONSITE INTERVIEW · Seen Dec 2026
  • Constant-Time Set OperationsPHONE SCREEN · Seen Sep 2026
  • Rasterize a Circle with Integer PixelsONSITE INTERVIEW · Seen Sep 2026
  • Racing ResultsOA · Seen Oct 2024
  • Find DoublesOA · Seen Oct 2024
  • Set Command SimulationONSITE INTERVIEW · Seen Aug 2024
  • Count Different Palindrome SubstringsOA · Seen Jul 2024
  • Count Palindromic SubstringsOA · Seen Jul 2024
  • Bakery Quality ControlOA · Seen Nov 2023

Similar questions at other companies

  • Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
  • Find Sliding-Window Pattern Start IndicesVisa · OAVisa interview questions
  • Get Special Substring (MTS)Salesforce · OASalesforce interview questions
  • Longest Cipher (Intuit India)Intuit · OAIntuit interview questions
  • Perfect SubstringAXQ Capital · OA
  • Incident MonitorStripe · OAStripe interview questions
  • Maximum Valid Substring FrequencyMicrosoft · OAMicrosoft interview questions
  • Same Substring Within BudgetJP Morgan Chase · OAJP Morgan Chase interview questions
  • Longest Distinct StringSuperhuman · OASuperhuman interview questions
  • K Smallest SubstringAkuna Capital · OAAkuna Capital interview questions
All Pure Storage interview questionsSee Pure Storage hiring insights
Saved
class Solution {
    public int findRepetitions(String short_s, String long_s) {
      // write your code here
    }

}
Checking account…