FastPrepLongest Frequency-Bounded Subarray
Problems/Longest Frequency-Bounded Subarray

Longest Frequency-Bounded Subarray

ZipRecruiter logoZipRecruiter● MediumFULLTIMENEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two ZipRecruiter OA reports preserve maximum contiguous length and a per-value frequency threshold; examples resolve one conflicting prose phrase. One source lacks an employment label, so FULLTIME and NEW GRAD are retained.

Return the maximum length of a contiguous subarray in which no distinct value occurs more than k times.

Function

longestFrequencyBoundedSubarray(values: int[], k: int) → int

Examples

Example 1

values = [1,1,2,3]k = 1return = 3

The maximum follows the per-value frequency bound.

Example 2

values = [1,2,1,3,2]k = 1return = 3

The maximum follows the per-value frequency bound.

Constraints

  • 1 <= values.length <= 100000
  • 1 <= k <= values.length

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024
  • Count Case-Insensitive Key ChangesOA · Seen Sep 2024

Similar questions at other companies

  • 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
  • Shortest Subarray Covering an Integer RangeMarshall Wace · OAMarshall Wace interview questions
  • Count Subarrays with at Least K Distinct ValuesVisa · OAVisa interview questions
  • Find Subarray With Minimum Distinct IntegersAmazon · OA

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public int longestFrequencyBoundedSubarray(int[] values, int k) {
        // Write your code here.
    }

}
Checking account…