FastPrepCount Length-Three Windows with Matching Ends
Problems/Count Length-Three Windows with Matching Ends

Count Length-Three Windows with Matching Ends

Visa logoVisa● EasyFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A December 10, 2025 Visa CodeSignal OA report states that a length-three window counts when its first and last characters match, and its longer example yields cxc and ccc. The same report lists abc as 1 despite a not matching c; this practice item records that isolated sample as a source typo and follows the stated rule and corroborating longer example.

You are given a string text.

Count the contiguous substrings of length exactly 3 whose first and last characters are equal. Windows may overlap. Return the count.

Function

countMatchingEndpointTriples(text: String) → int

Examples

Example 1

text = "abcxccc"return = 2

The matching windows are cxc and ccc.

Example 2

text = "aba"return = 1

The only length-three window begins and ends with a.

Example 3

text = "ab"return = 0

A string shorter than three characters contains no eligible window.

Constraints

  • 0 <= text.length <= 2 * 105
  • text contains printable ASCII characters.

More Visa Online Assessment questions

  • Count Prime Values in SubtreesOA · Seen Nov 2026
  • Lock CodeOA · Seen Nov 2026
  • Minimum-Sum Tree Fill with Unit StepsOA · Seen Nov 2026
  • Longest Non-Decreasing Substring After Pair SwapsOA · Seen Oct 2026
  • Count Attack Vectors by Divisor RangeOA · Seen Oct 2026
  • Minimum Operations to Reduce a Transaction LedgerOA · Seen Oct 2026
  • Count Valid Space-Delimited WordsOA · Seen Oct 2026
  • Earliest Common Meeting StartOA · Seen Oct 2026
  • Maximum Index-Weighted Sum with Disjoint SwapsOA · Seen Oct 2026
  • Maximum Equalized Substrings After One Adjacent SwapOA · Seen Sep 2026

Similar questions at other companies

  • Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
  • Get Special Substring (MTS)Salesforce · OASalesforce interview questions
  • Longest Cipher (Intuit India)Intuit · OAIntuit interview questions
  • Find RepetitionsPure Storage · OAPure Storage 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 Visa interview questionsSee Visa hiring insights
Saved
class Solution {
    public int countMatchingEndpointTriples(String text) {
        // Write your code here.
    }

}
Checking account…