Sum Consecutive Identical Digits
Reported by candidates from PayPay's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
PayPay's June 2025 OA included a string problem that looks simple on the surface: sum consecutive identical digits. You see it and think brute force, then realize the sliding window trick saves you from messy edge cases. The pattern is classic but the implementation matters. StealthCoder catches the off-by-one errors that sink candidates who code blind under pressure.
Pattern and pitfall
The core idea: iterate through the string, identify runs of the same digit, multiply the digit by the run length, and add to a sum. A naive scan works but sliding window is cleaner. Maintain a pointer at the start of each run, advance until the digit changes, calculate the contribution, then move to the next run. Common pitfall: forgetting the final run after the loop exits, or miscounting the run length. The trick isn't algorithmic complexity, it's clean state management. StealthCoder gives you the scaffolding if you blank on the loop structure.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Sum Consecutive Identical Digits cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass PayPay's OA.
PayPay reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Sum Consecutive Identical Digits FAQ
Is this really a sliding window problem?+
Yes, but not the fast/slow pointer kind. It's a fixed-window that shrinks conceptually as you identify each run of identical digits. Advance one pointer, hold another, calculate the gap. Much cleaner than nested loops.
What's the common mistake?+
Forgetting to process the final run after the main loop ends. You'll iterate up to the second-to-last character, then exit, leaving the last digit group unprocessed. Always handle the tail case explicitly.
Do I need to convert chars to ints?+
Yes. You're summing digit values, not ASCII codes. Convert each character to an integer, multiply by the run length, and accumulate. Easy but easy to skip if you're rushing.
What if the string has only one digit?+
Return that digit multiplied by 1. Your loop should handle this naturally, but verify your edge case logic doesn't assume multiple runs. Test with single-character input.
How do I prepare for this in 48 hours?+
Practice one string iteration problem with runs or groups. Focus on loop termination and final-run handling, not algorithmic insight. The PayPay version likely tests precision, not creativity. Code it twice cleanly.