FastPrepFind Consistent Logs
Problems/Find Consistent Logs

Find Consistent Logs

Citadel logoCitadel● HardINTERNOA

Updated Jul 2026

QuestionFunctionExamplesConstraints

Problem statement

The developers working on a social media network app want to analyze user behavior. There are n event logs where userEvent[i] denotes the userId for the user that triggered the ith event. The team wants to analyze the subarray of the logs which are consistent, that is, the frequency of the most frequent user in the subarray is equal to the frequency of the least frequent user in the whole array. Find the maximum length of consistent logs.

Note: A subarray is a contiguous group of elements in an array.

Function

findConsistentLogs(userEvent: int[]) → int

Complete the function findConsistentLogs in the editor 👉👉.

findConsistentLogs has the following parameters:

  1. int userEvent[n]: the userIds present in the event logs

Returns

int: the maximum length of consistent logs

𓇢𓆸, Credit to 𓇼 ⋆。˚Rachel 𓆝⋆。˚ 𓇼°

Examples

Example 1

userEvent = [1, 2, 1, 3, 4, 2, 4, 3, 3, 4]return = 8
* The frequencies of 1 and 2 are 2 * The frequencies of 3 and 4 are 3 The minimum frequency in the array is 2 The longest valid subarray has 8 elements: [1, 2, 1, 3, 4, 2, 4, 3] * The frequencies of 1, 2, 3, and 4 are all 2. The frequenccy of the most common element in the subarray is 2, the same as the min frequency in the entire array. Hence, the max len of the consistent logs is 8 :)

Constraints

  • 1 <= n <= 3 * 105
  • 1 <= userEvent[i] <= 109

More Citadel interview questions

  • 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
  • Merge Price-Delta FeedsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Incident MonitorStripe · OAStripe interview questions
  • Get Maximum CountAmazon · OA
  • Find Consistent LogsGoogle · OAGoogle interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Count Subarrays with at Least K Equal-Fruit PairsTikTok · OATikTok interview questions
  • Consistent LogsRippling · OARippling interview questions
  • Minimum Length Good SubarrayMicrosoft · OAMicrosoft interview questions
  • Auction Sniping Window MinimumCisco · OACisco interview questions
  • Balanced Prefix Sets in a PermutationUber · OAUber 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 findConsistentLogs(int[] userEvent) {
      // write your code here :)
    }

}
Checking account…