Question bank › Two Pointers
Dsa Two Pointers Easy

Harvesting Crops

You are a farmer with a field represented by an array of integers where each integer represents the amount of a specific crop type found in that section of the field. You want to maximize your crop harvest by selecting a continuous section of the field such that the sum of the crops in that section is maximized, but you can only take from each crop type once. Write a function that takes the array of crop amounts and returns the maximum harvest possible. Input Format: - A single line containing space-separated integers representing the crop amounts. Output Format: - A single integer representing the maximum harvest. Example: Input: 2 1 3 5 1 2 8 3 Output: 14

Key concepts

two_pointersarraygreed

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.