FastPrepSum Consecutive Identical Digits
Problems/Sum Consecutive Identical Digits

Sum Consecutive Identical Digits

PayPay logoPayPay● EasyFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

Given a string digits consisting only of decimal digits, repeatedly combine adjacent identical digits until no such pair remains.

At each step, choose the leftmost pair of identical adjacent digits. Replace that pair with the decimal representation of the sum of their numeric values, then restart the search from the beginning of the updated string.

For digits = "99823":

  1. The leftmost pair 99 becomes 18, producing 18823.
  2. The leftmost pair 88 becomes 16, producing 11623.
  3. The leftmost pair 11 becomes 2, producing 2623.

No identical adjacent digits remain, so return "2623".

Complete sumConsecutiveIdenticalDigits, which takes digits and returns the final string.

Function

sumConsecutiveIdenticalDigits(digits: String) → String

Examples

Example 1

digits = "99823"return = "2623"
  • 99 becomes 18 → 18823
  • 88 becomes 16 → 11623
  • 11 becomes 2 → 2623

Now there are no more consecutive identical digits, so output the final result: 2623.

More PayPay interview questions

  • Next Greater Value in a Circular ArrayPHONE SCREEN · Seen Sep 2026
  • Palindromic Array TransformationOA · Seen Nov 2023
  • Calculate ChangeOA · Seen Feb 2022
  • Find Maximum Two-Digit FragmentPHONE SCREEN · Seen Sep 2021

Similar questions at other companies

  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • Branch with the Most FilesCapital One · OACapital One interview questions
  • REST API: Highest International StudentsRippling · OARippling interview questions
  • Rearrange String by Alternating EndsHudson River Trading · OAHudson River Trading interview questions
  • Filter Isolated Interior Signal BitsSEDEMAC · OA
  • Scale Ingredient QuantitiesUpstart · OAUpstart interview questions
  • Telephone Keypad String EncodingEpic · OAEpic interview questions
  • Count Invalid Log GroupsIBM · OAIBM interview questions
  • Count Case-Insensitive TripletsTikTok · OATikTok interview questions
  • Simulate a Deterministic Finite AutomatonPoint72 · OAPoint72 interview questions
All PayPay interview questionsSee PayPay hiring insights
Saved
class Solution {
    public String sumConsecutiveIdenticalDigits(String digits) {
      // write your code here
    }

}
Checking account…