FastPrepPicking Tickets
Problems/Picking Tickets

Picking Tickets

Vanguard logoVanguard● EasyNEW GRADINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names Picking Tickets and describes sorting followed by a scan for the longest run. The rule for adjacent differences, how duplicates are handled, and the limits are our assumptions. Our version is about 65% the same as the reported question.

Given an array of ticket values tickets, choose as many tickets as possible. You may reorder the chosen tickets.

After ordering them from smallest to largest, the difference between every pair of neighboring values must be at most 1. Equal values are allowed, and each duplicate is a separate ticket.

Return the maximum number of tickets you can choose. A chain may span more than two distinct values; the rule applies to neighboring values in the sorted selection.

Function

maxTickets(tickets: int[]) → int

Examples

Example 1

tickets = [8,5,4,8,4]return = 3

Choose [4,4,5]. The two 8 tickets form a smaller valid group.

Example 2

tickets = [3,1,2]return = 3

Reorder to [1,2,3]. Both neighboring differences equal 1, so the whole chain qualifies.

Constraints

  • 1 <= tickets.length <= 10^5.
  • 1 <= tickets[i] <= 10^9.

More Vanguard Online Assessment questions

  • Two SumOA · Seen Sep 2026
  • Valid ParenthesesOA · Seen Sep 2026
  • Are They PangramsOA · Seen Nov 2025
  • Missing WordsOA · Seen Nov 2025
  • Spam DetectionOA · Seen Nov 2025
  • Binge WatchingOA · Seen Jan 2023
  • Minimum Moves Around a Circular ArrayOA · Seen Aug 2022
  • Maximum Occurring CharacterOA · Seen Mar 2022
  • Tool List: Two Smallest ValuesOA · Seen Nov 2021
  • Group AnagramsOA · Seen Nov 2019

Similar questions at other companies

  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
  • Rank Football TeamsCapital One · OACapital One interview questions
  • Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
  • Rank Football TeamsPersona · OAPersona interview questions
  • Meandering ArrayVerisk · OA
  • Minimum Magic Stones After MergesElevenLabs · OAElevenLabs interview questions
  • Find Top Two TeamsAutodesk · OAAutodesk interview questions
  • Total Server DowntimeVisa · OAVisa interview questions

Interview reports that mention this question

  • Vanguard Tech and Risk Older OAs: 12 Experiences (Part 3 of 3)
  • Vanguard Software Older Rounds: 13 Experiences (Part 2 of 3)
  • Vanguard Tech Intern Interviews: 37 Experiences (Part 1 of 3)
All Vanguard interview questionsSee Vanguard hiring insights
Saved
class Solution {
    public int maxTickets(int[] tickets) {
        // Write your code here.
    }
}
Checking account…