Find Consistent Logs
Updated
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:
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 = 8Constraints
1 <= n <= 3 * 1051 <= 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