FastPrepLexicographically Largest String with a Repeat Limit
Problems/Lexicographically Largest String with a Repeat Limit

Lexicographically Largest String with a Repeat Limit

Adobe logoAdobe● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Adobe online assessment for full-time roles. The report describes a repeat-limited largest string over 26 letters. But its example, baccc with k=2, gives ccba. Under its stated rule, ccbca is larger and valid. Our version follows the stated rule about consecutive repeats. We added clear limits, and we allow leaving letters unused. Our version is about 94% the same as the reported question.

Rearrange any number of letters from s to form the lexicographically largest possible string. You may use each occurrence at most once and may leave letters unused. No letter may appear more than k times consecutively.

Use ordinary lowercase English order. When one string is a prefix of another, the longer string is larger. The objective is lexicographic order, with no separate maximum-length requirement.

Function

repeatLimitedString(s: String, k: int) → String

Examples

Example 1

s = "baccc"k = 2return = "ccbca"

Start with cc, use b to break the run, then append c and a. The result ccbca obeys the limit and is larger than ccba, because its fourth letter is larger.

Example 2

s = "zzzzza"k = 2return = "zzazz"

Use two z letters, the only a as a separator, and two more z letters. The remaining z cannot be appended without making three consecutive z letters.

Constraints

  • For this exercise, assume 1 <= s.length <= 100000.
  • s contains only lowercase English letters.
  • For this exercise, assume 1 <= k <= 100000.

Source note: Original OA task images and any included source example. The practice contract follows the rules stated in the problem and source note.

More Adobe Online Assessment questions

  • Base Unit ConversionsOA · Seen Nov 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Top-Funded Villages and ProjectsOA · Seen Aug 2026
  • Count Parent Nodes With a Target SumOA · Seen Aug 2026
  • Largest Binary Number by ConcatenationOA · Seen Aug 2026
  • Count Events by CategoryOA · Seen Aug 2026
  • Graph M-ColoringOA · Seen Aug 2026
  • Hall of Shifting TilesOA · Seen Aug 2026
  • K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
  • Maze ReachabilityOA · Seen Aug 2026

Similar questions at other companies

  • Maximum String OperationsMicrosoft · OAMicrosoft interview questions
  • Minimum No-Repeat Segments After One Character RemovalSalesforce · OASalesforce interview questions
  • Longest Non-Decreasing Substring After Pair SwapsVisa · OAVisa interview questions
  • Minimum Deletion Cost for Distinct Adjacent CharactersHSBC · OAHSBC interview questions
  • Minimum Binary Swaps to a PalindromeAT&T · OAAT&T interview questions
  • Robot Assembly Line ConflictsGoogle · OAGoogle interview questions
  • Substring RemovalJP Morgan Chase · OAJP Morgan Chase interview questions
  • Minimum Additions to Make a Valid ABC StringIBM · OAIBM interview questions
  • Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
  • Minimum Adjacent TranspositionsEpic · OAEpic interview questions

Adobe interview experiences

  • Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public String repeatLimitedString(String s, int k) {
        // Write your solution here.
    }

}
Checking account…