BackmediumArrays Oracle

Galactic Resource Optimization Solution

Problem Statement

Given an array of resource values on each planet and a limit of 7 space missions, find the maximum resources that can be collected by visiting planets in a cyclic manner, where each mission must start and end at the same planet. The planets can be visited in any order.

Example 1
Input
[10, 20, 30, 40, 50, 60, 70, 10]
Output
290

Explanation: Step-by-step: with input [10, 20, 30, 40, 50, 60, 70, 10], we start at planet 0, visit planets 1, 2, 3, 4, 5, 6, and then return to planet 0, giving output 290.

Example 2
Input
[100, 200, 300, 400, 500, 600, 700]
Output
2100

Explanation: Step-by-step: with input [100, 200, 300, 400, 500, 600, 700], we start at planet 0, visit planets 1, 2, 3, 4, 5, 6, and then return to planet 0, giving output 2100.

Constraints

  • 1 <= resources.length <= 1000
  • 1 <= missions <= resources.length
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free