FastPrepMaximize the Lottery ID
Problems/Maximize the Lottery ID

Maximize the Lottery ID

Citadel logoCitadel● HardINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

The newspaper HackerRankNews distributed lottery tickets to everyone, and the winning lottery ID is described in the paper denoted by winnerID.

In order to win the lottery, a customer having a lottery ID denoted by lotteryID needs to maximize the length of the longest common subsequence of the strings lotteryID and winnerID. To do so, the customer can perform up to k operations. In each operation, the customer can change any character in lotteryID either to its next or previous character.

Find the maximum possible length of the longest common subsequence after at most k such operations.

Note:

  • Operations can be performed only on lotteryID, not on winnerID.
  • The next character of a given character ch is the character that comes just after it in the alphabet. Similarly, the previous character is the character that comes just before it in the alphabet. For example, the next character of 'm' is 'n' and the previous is 'l'. For 'z' the next character is 'a' and for 'a' the previous character is 'z'.

Function

maximizeLotteryID(lotteryID: String, winnerID: String, k: int) → int

Examples

Example 1

lotteryID = "fpelqanxyk"winnerID = "hackerrank"k = 6return = 7

One of the optimal ways to perform the operations is as follows:

  1. Select i = 0 and move lotteryID[0] to its next character: "gpelqanxyk".
  2. Select i = 0 again: "hpelqanxyk".
  3. Select i = 2 and move lotteryID[2] to its previous character: "hpdlqanxyk".
  4. Select i = 2 again: "hpclqanxyk".
  5. Select i = 3 and move lotteryID[3] to its previous character: "hpckqanxyk".
  6. Select i = 4 and move lotteryID[4] to its next character: "hpckranxyk".

The transformed lottery ID and winnerID have a longest common subsequence of length 7; for example, "hckrank". Therefore, the maximum possible length after at most k operations is 7.

Constraints

  • 1 <= lotteryID.length, winnerID.length <= 100
  • 0 <= k <= 200

More Citadel interview questions

  • Merge Price-Delta FeedsPHONE SCREEN · Seen Dec 2026
  • Speed Up a Slow FunctionOA · PHONE SCREEN · Seen Nov 2026
  • Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
  • Square Root FunctionPHONE SCREEN · Seen Oct 2026
  • Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
  • Spreadsheet Formula DependenciesPHONE SCREEN · Seen Oct 2026
  • Possible MEX Values After One Optional IncrementOA · Seen Oct 2026
  • Currency Arbitrage CyclePHONE SCREEN · Seen Sep 2026
  • Order Book with Cancel by Order IDPHONE SCREEN · Seen Sep 2026
  • Smart Queue of Latest PricesPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Minimum Merge ConflictsAmazon · OA
  • Lexicographically Smallest Grid Path with One Letter ChangeInfosys · OAInfosys interview questions
  • String Formation (Also for AI/ML Software Engineer Intern :)Snowflake · OASnowflake interview questions
  • Longest Subsequence which is a SubstringSalesforce · OASalesforce interview questions
  • Distinct MovesMeesho · OA
  • Compressed Representation SizeMicrosoft · OAMicrosoft interview questions
  • Find Minimum OperationsIBM · OAIBM interview questions
  • String Challenge (Generic)TikTok · OATikTok interview questions
  • Sum of All ValuesFlexport · OAFlexport interview questions
  • Maximum Crayon Removal ScoreWells Fargo · OAWells Fargo interview questions

Citadel interview experiences

  • Citadel Securities Quant Researcher Intern Loop: 1 Experience
  • Citadel Securities Research Engineer Interview: 1 Experience
  • Citadel Securities SWE Intern First Round: 2 Experiences
  • Citadel Securities Experienced SWE Interviews: 1 Experience
  • Citadel SWE Intern Later Rounds and Superday: 13 Experiences
  • Citadel SWE Intern First-Round Questions: 20 Experiences
All Citadel interview questionsSee Citadel hiring insights
Saved
class Solution {
    public int maximizeLotteryID(String lotteryID, String winnerID, int k) {
        // write your code here
    }

}
Checking account…