FastPrepUsername Change
Problems/Username Change

Username Change

Roblox logoRoblox● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives a username-swapping task with foo giving false, bar giving true, and rim giving true. This version asks whether one swap can make a strictly smaller username. We chose lowercase input, what happens with empty input, and the limits. Our version is about 90% the same as the reported question.

You are given a list of usernames names. For each username, decide whether swapping two characters at different positions can produce a lexicographically smaller string.

For this exercise, assume each username contains lowercase English letters. One swap exchanges exactly two existing positions. Compare the new string with the original: at the first differing position, a smaller letter makes the new string smaller. It does not have to be fully sorted.

Return a Boolean array in input order. A username of length less than two cannot be improved. Swapping equal letters leaves the string unchanged, so it does not count as an improvement.

Function

canImproveUsernames(names: String[]) → boolean[]

Examples

Example 1

names = ["foo","bar","rim"]return = [false,true,true]

foo has no smaller letter after a larger one. Swapping b/a makes bar become abr, and swapping r/i makes rim become irm, which is smaller even though it is not sorted.

Example 2

names = ["aa","z",""]return = [false,false,false]

Equal-letter swaps do not change aa. A one-character or empty name has no pair of positions.

Example 3

names = ["ba","ab","cba"]return = [true,false,true]

ba and cba can move a smaller later letter to an earlier position; ab is already nondecreasing.

Constraints

  • 0 <= names.length <= 100.
  • 0 <= names[i].length <= 1000; total username length is at most 5000.
  • All characters are lowercase English letters.

More Roblox Online Assessment questions

  • Centered Block Placement QueriesOA · Seen Oct 2026
  • Robot Navigation Around LasersOA · Seen Oct 2026
  • Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
  • Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
  • Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
  • Track Received Byte RangesOA · Seen Sep 2026
  • Inventory Discount TrackerOA · Seen Sep 2026
  • Break a PalindromeOA · Seen Jun 2026
  • Count Pairs Differing in One DigitOA · Seen Oct 2025
  • Find Zero Cells in a 2×2 GridOA · Seen Oct 2025

Similar questions at other companies

  • Maximum Ones After K OperationsGoldman Sachs · OAGoldman Sachs interview questions
  • Minimum Operations to Reduce a Transaction LedgerVisa · OAVisa interview questions
  • Prepare NotificationMicrosoft · OAMicrosoft interview questions
  • Minimum Changes for Distinct Adjacent CharactersHeadlands Technologies · OAHeadlands Technologies interview questions
  • Largest Number With Even Digit FrequenciesDRW · OADRW interview questions
  • Minimum Replacements for Unequal Adjacent CharactersIBM · OAIBM interview questions
  • Crop Text at a Whole-Word BoundaryAmerican Express · OAAmerican Express interview questions
  • Minimum Flips for Even Binary RunsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Missing WordsVanguard · OAVanguard interview questions
  • Digit Changes for a Multiple of 9Nutanix · OANutanix interview questions

Interview reports that mention this question

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)

Roblox interview experiences

  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public boolean[] canImproveUsernames(String[] names) {
        // write your code here
    }

}
Checking account…