FastPrepDigit Pair With Three Question Marks Between
Problems/Digit Pair With Three Question Marks Between

Digit Pair With Three Question Marks Between

Capital One logoCapital One● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A 2021 Capital One report from a software engineer candidate lists this in the algorithms round of the final day. The task is to decide whether a string has two numbers that add up to 10 with exactly three question marks between them. It gives one sample string, which is used here as Example 1.

The report does not say which pairs count or what else the string holds. Here each number is a single digit. Only neighbouring digits (no digit between them) form a pair. The question marks are counted between them while letters are ignored, and one such pair is enough. The string has lowercase letters, digits and question marks, up to 1000 characters. These are our choices.

Our version is about 80% the same as the reported question.

The string s holds lowercase letters, digits and question marks. Read its digits from left to right; two digits are neighbours when no other digit lies between them.

Return true if some pair of neighbouring digits adds up to 10 and has exactly three ? characters between them. Letters between the two digits are ignored. Otherwise return false.

Function

hasMarkedPair(s: String) → boolean

Examples

Example 1

s = "3shrhe??4??s?des6"return = true

The digits in order are 3, 4 and 6. Between 3 and 4 there are two question marks, and 3 + 4 = 7. Between 4 and 6 there are three question marks (the letters in between do not count), and 4 + 6 = 10. So the answer is true.

Example 2

s = "64???6"return = true

Each digit stands alone, so 64 is the digit 6 next to the digit 4. That first pair adds up to 10 but has no question marks between it. The pair 4, 6 also adds up to 10 and has exactly three marks between it. One such pair is enough, so the answer is true.

Example 3

s = "2????8a4???4"return = false

The pair 2, 8 adds up to 10, but four question marks sit between them, not three. The other neighbouring pairs, 8, 4 and 4, 4, add up to 12 and 8. The answer is false.

Example 4

s = "2?5??8"return = false

Exactly three question marks lie between 2 and 8, and 2 + 8 = 10, but the digit 5 sits between them, so they are not neighbours. The neighbouring pairs 2, 5 and 5, 8 add up to 7 and 13. The answer is false.

Constraints

  • 1 <= s.length <= 1000
  • s contains only lowercase English letters, digits and ?.

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Christmas Tree with N TiersVerily · ONSITE INTERVIEW
  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Valid ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
  • Longest Spoken PrefixElevenLabs · ONSITE INTERVIEWElevenLabs interview questions
  • Palindrome Check Ignoring SymbolsWalmart · ONSITE INTERVIEWWalmart interview questions
  • Reverse a String Keeping Dashes in PlaceNykaa · ONSITE INTERVIEWNykaa interview questions
  • Implement tail -nConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Valid ParenthesesEPAM · ONSITE INTERVIEWEPAM interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions

Capital One interview experiences

  • Capital One Coding OA Questions: 3 Experiences
  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public boolean hasMarkedPair(String s) {
        // Write your code here.
    }
}
Checking account…