FastPrepFind Consistent Logs
Problems/Find Consistent Logs

Find Consistent Logs

Google logoGoogle● HardOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

The organizers of a gaming tournament want to analyze player participation based on event logs. There are n event logs, where arr[i] indicates the playerId of the player who participated in the ith event. The organizers need to identify subarrays of these logs that are consistent, meaning that the frequency of the most frequent player in the subarray matches the frequency of the least frequent player in the entire array. Determine the maximum length of such consistent logs.

Function

findConsistentLogs(arr: int[]) → int

Complete the function findConsistentLogs with the following parameters:

int arr[n]: the playerIds present in the event logs

Returns int: the maximum length of the consistent logs

Examples

Example 1

arr = [1, 2, 1, 3, 4, 2, 4, 3, 3, 4]return = 8

Given:

  • n = 10
  • arr = [1, 2, 1, 3, 4, 2, 4, 3, 3, 4]

The frequencies of playerIds 1 and 2 are 2. The frequencies of playerIds 3 and 4 are 3. The minimum frequency in the array is 2. The longest valid subarray with this property is [1, 2, 1, 3, 4, 2, 4, 3], which has 8 elements. In this subarray, the most common element appears 2 times, which matches the minimum frequency in the entire array. Therefore, the maximum length of consistent logs is 8.

Constraints

  • 1 <= arr.length <= 10^4
  • 1 <= arr[i] <= 10^9

More Google interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Operations to Make a SubsequenceOA · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Incident MonitorStripe · OAStripe interview questions
  • Get Maximum CountAmazon · OA
  • Find Consistent LogsCitadel · OACitadel 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

Interview reports that mention this question

  • Google OA: What It Tests (2026)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int findConsistentLogs(int[] arr) {
      // write your code here
    }

}
Checking account…