FastPrepK-Group Digit-Sum Compression
Problems/K-Group Digit-Sum Compression

K-Group Digit-Sum Compression

ZipRecruiter logoZipRecruiter● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes repeated sums of k-sized digit groups, a shorter last group, the rule of stopping when the length is at most k, and examples for k=3 and k=5. We supplied limits and a function signature.

While digits.length > k, split it into consecutive groups of length k, allowing a shorter final group. Replace each group by its decimal digit sum and concatenate the replacements.

Return the first string whose length is at most k.

Function

compressDigitGroups(digits: String, k: int) → String

Examples

Example 1

digits = "1111122222"k = 3return = "132"

Repeated group-sum passes end at 132.

Example 2

digits = "1111122222"k = 5return = "510"

The two length-five groups sum to 5 and 10, producing 510.

Constraints

  • 1 <= digits.length <= 100000
  • 2 <= k <= 100000

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Branch with the Most FilesCapital One · OACapital One interview questions
  • Robot Stops Left or Right (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge 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

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public String compressDigitGroups(String digits, int k) {
        // Write your code here.
    }

}
Checking account…