FastPrepDecode Numeric String
Problems/Decode Numeric String

Decode Numeric String

Arcesium logoArcesium● MediumFULLTIMEONSITE INTERVIEW

Updated Jul 2026

QuestionFunctionExamplesConstraints

Problem statement

A message is encoded by mapping letters to numbers: A -> 1, B -> 2, ..., Z -> 26.

Given a numeric string digits, return the number of different ways it can be decoded into letters.

A one-digit code is valid when it is between 1 and 9. A two-digit code is valid when it is between 10 and 26.

Function

countDecodings(digits: String) → int

Examples

Example 1

digits = "2116"return = 5

The valid decodings split the string as 2,1,1,6, 21,1,6, 2,11,6, 2,1,16, and 21,16.

Constraints

  • 1 <= digits.length <= 10^5
  • digits consists of numeric characters.
  • The number of valid decodings is guaranteed to fit in a signed 32-bit integer.

More Arcesium interview questions

  • Ordered Payload ReleaseONSITE INTERVIEW · Seen Jul 2026
  • Tree Ancestor QueriesONSITE INTERVIEW · Seen Jun 2026
  • City Infection NumberOA · Seen Jul 2025
  • Minimum Tunnel Crossing TimeOA · Seen Jul 2025
  • Product of Subset MaximaOA · Seen Jul 2025
  • Reconstruct the Root StreamOA · Seen Jul 2025
  • Add DigitsOA · Seen Aug 2023
  • Binary Tree Maximum Path SumOA · Seen Aug 2023
  • Detect a Cycle in Directed Hate RelationshipsOA · Seen Aug 2023
  • Reverse First K Characters in Every 2K BlockOA · Seen Aug 2023

Similar questions at other companies

  • Maximum Bouquet ValueOracle · ONSITE INTERVIEWOracle interview questions
  • Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Word BreakGoogle · ONSITE INTERVIEWGoogle interview questions
  • Reconstruct One Sentence From a DictionaryMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Scramble StringExpedia · ONSITE INTERVIEWExpedia interview questions
  • Word BreakMoveworks · ONSITE INTERVIEWMoveworks interview questions
  • Validate a Palindrome After Limited DeletionsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Word BreakBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Count Vowel PermutationsZscaler · ONSITE INTERVIEWZscaler interview questions
  • Minimum Steps on a Circular Character DialNavan · ONSITE INTERVIEWNavan interview questions
All Arcesium interview questionsSee Arcesium hiring insights
Saved
class Solution {
    public int countDecodings(String digits) {
      // write your code here
    }
}
Checking account…