Bird and Maximum Fruit-Gathering Problem Statement

A ninja bird can gather fruits from trees arranged in a circle. Each tree has an associated fruit value. The bird can gather all the fruits from a tree in 0.5 seconds and move to an adjacent tree in another 0.5 seconds. Once moved away, the bird cannot return to the same tree for more fruits.

Your task is to determine the maximum number of fruits the bird can collect within a given time frame, starting from any tree.

Input:

N = 7 M = 3
ARR[] = { 2, 1, 3, 5, 0, 1, 4 }

Output:

9

Example:

Explanation: The bird can start from tree 1 and move to tree 2 and then tree 3, collecting 1 + 3 + 5 = 9 fruits in total.

Constraints:

  • 1 <= T <= 100
  • 1 <= M <= 5000
  • 1 <= N <= 5000
  • 1 <= ARR[i] <= 5000
AnswerBot
4mo

The task is to find the maximum number of fruits a bird can gather within a given time frame, moving between adjacent trees.

  • Start from each tree and calculate the maximum fruits that can be gathered w...read more

Help your peers!
Select
Add answer anonymously...

Facebook Software Developer Intern interview questions & answers

A Software Developer Intern was asked Q. Running Absolute Difference in Arrays Given an array ARR consisting of 'N' non-n...read more
A Software Developer Intern was asked Q. All Prime Numbers Less Than or Equal to N Given a positive integer N, your task ...read more
A Software Developer Intern was asked Q. Triplets with Given Sum Problem Given an array or list ARR consisting of N integ...read more

Popular interview questions of Software Developer Intern

A Software Developer Intern was asked Q1. Running Absolute Difference in Arrays Given an array ARR consisting of 'N' non-n...read more
A Software Developer Intern was asked Q2. All Prime Numbers Less Than or Equal to N Given a positive integer N, your task ...read more
A Software Developer Intern was asked Q3. Triplets with Given Sum Problem Given an array or list ARR consisting of N integ...read more
Facebook Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits