FastPrepRoll the String
Problems/Roll the String

Roll the String

Microsoft logoMicrosoft● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Microsoft intern online assessment. The report does not give limits on the numbers. The task and the example in the report match our version at about 99%.

A single roll operation increments each character by one cyclically within the lowercase English alphabet. For example, a becomes b, b becomes c, and z becomes a.

Given a string s and an integer array roll, process every value roll[i] in array order. For each value, roll the first roll[i] characters of s once.

Return the resulting string after all roll operations have been applied.

Function

rollTheString(s: String, roll: int[]) → String

Examples

Example 1

s = "abz"roll = [3,2,1]return = "dda"

Apply the rolls in order:

  1. roll[0] = 3: roll all three characters, so abz becomes bca.
  2. roll[1] = 2: roll the first two characters, so bca becomes cda.
  3. roll[2] = 1: roll the first character, so cda becomes dda.

The final value of s is dda.

Constraints

  • 1 <= s.length <= 10^5.
  • 1 <= roll.length <= 10^5.
  • s contains only lowercase English letters.
  • 1 <= roll[i] <= s.length for every valid index i.

More Microsoft Online Assessment questions

  • Maximum Score with Prime JumpsOA · Seen Dec 2026
  • Minimum Non-Adjacent Selection CapabilityOA · Seen Dec 2026
  • Authentication SystemOA · Seen Nov 2026
  • Maximum String OperationsOA · Seen Nov 2026
  • Minimum Cost to Process Priority TasksOA · Seen Nov 2026
  • Most Visited Sprint MarkerOA · Seen Nov 2026
  • Maximum Escape Game ScoreOA · Seen Nov 2026
  • Count Subarrays with a Perfect-Square ProductOA · Seen Nov 2026
  • Maximum Interactive Team SizeOA · Seen Nov 2026
  • Maximize Pipeline Throughput Under a Scaling BudgetOA · Seen Nov 2026

Similar questions at other companies

  • Earliest Time to Schedule a MeetingMathWorks · OAMathWorks interview questions
  • Earliest Meeting Start on a 24-Hour ClockIMC Trading · OAIMC Trading interview questions
  • Stars Between Bars in RangesExpedia · OAExpedia interview questions
  • Prefix-Length Letter ShiftsChewy · PHONE SCREEN
  • Count Lamps Lighting Each PointAirbnb · OAAirbnb interview questions
  • Count One-Swap Number PairsCapital One · OACapital One interview questions
  • Find a String Within One Mismatch of AllBarclays · OABarclays interview questions
  • Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
  • Count Subarrays Matching a Comparison PatternTikTok · OATikTok interview questions
  • Split a Matrix Into Four Partitions by Average (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public String rollTheString(String s, int[] roll) {
        // write your code here
    }
}
Checking account…