FastPrepMaximize Fish over Limited Hours
Problems/Maximize Fish over Limited Hours

Maximize Fish over Limited Hours

ByteDance logoByteDance● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report defines ponds whose yield goes down and asks to add up the catch faster than simulating each hour with a heap. We chose to round down so the result is never below zero. Our version is about 96% the same as the reported question.

You are given initial hourly fish yields yields for several ponds and a number of fishing hours hours. In each hour, choose exactly one pond, collect its current yield, and decrease that pond's future yield by one without going below zero.

Return the maximum total fish that can be collected. Your solution should combine the work for whole yield levels instead of using a heap to simulate one hour at a time.

Function

maximizeFish(yields: int[], hours: long) → long

Examples

Example 1

yields = [90,100]hours = 100return = 7075

The optimal schedule always takes a currently largest yield; aggregating the top one hundred available positive yields gives 7075.

Example 2

yields = [2,1]hours = 5return = 4

The positive collections are 2, 1, and 1; remaining hours contribute zero.

Constraints

  • 1 <= yields.length <= 200000
  • 0 <= yields[i] <= 1000000000
  • 1 <= hours <= 100000000000000
  • The answer fits signed 64-bit arithmetic.

More ByteDance Phone Screen questions

  • Largest Number Below N from Reusable DigitsPHONE SCREEN · Seen Nov 2026
  • Log Analyzer: Busiest Service in a Rolling WindowPHONE SCREEN · Seen Nov 2026
  • Majority ElementPHONE SCREEN · Seen Nov 2026
  • Valid ParenthesesPHONE SCREEN · Seen Nov 2026
  • Binary Tree Target-Sum PathsPHONE SCREEN · Seen Nov 2026
  • Longest Increasing SubsequencePHONE SCREEN · Seen Nov 2026
  • Alien DictionaryPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lexicographically Smallest Topological OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximum Number of Events That Can Be AttendedPHONE SCREEN · Seen Nov 2026
  • Implement Multi-Head AttentionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Aggressive CowsAmazon · PHONE SCREEN
  • Maximize the Minimum Cone DistanceSumo Logic · PHONE SCREEN
  • Minimize Maximum Group DifferenceDRW · OADRW interview questions
  • Minimum-Cost Solar Rooftop AllocationDeloitte · OADeloitte interview questions
  • Maximize Number of Produced CarsMicrosoft · OAMicrosoft interview questions
  • Aggressive CowsPeopleStrong · OAPeopleStrong interview questions
  • Spread Cows Across StallsExpedia · OAExpedia interview questions
  • Split Array to Minimize the Largest SumNation with NaMo · PHONE SCREEN
  • Median Across Sorted ArraysGoogle · PHONE SCREENGoogle interview questions
  • IPOTekion · PHONE SCREENTekion interview questions

ByteDance interview experiences

  • ByteDance TikTok USDS SWE Intern Interview: 1 Experience
  • ByteDance MLE New Grad Interviews: 1 Experience
  • ByteDance Security SRE Intern Phone Screens: 1 Experience
  • ByteDance USDS New Grad SWE Phone Screen: 1 Experience
  • ByteDance New Grad Data Engineer Video Interviews: 1 Experience
  • ByteDance Trust & Safety Research Scientist Intern: 1 Experience
All ByteDance interview questionsSee ByteDance hiring insights
Saved
class Solution {
    public long maximizeFish(int[] yields, long hours) {
        // Write your code here.
    }

}
Checking account…