Digit Pair With Three Question Marks Between
Updated
Problem statement
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) → booleanExamples
Example 1
s = "3shrhe??4??s?des6"return = trueThe 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 = trueEach 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 = falseThe 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 = falseExactly 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 <= 1000scontains 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