Tap here to switch tabs
Problem
Submissions

Problem: Collecting Chocolates

Try to solve the Collecting Chocolates problem.

Statement

You are given a 00 indexed integer array nums of length nn representing the initial cost of collecting chocolates of types 00 to n−1n - 1, where nums[i] denotes the cost of collecting a chocolate of type i.

You want to collect at least one chocolate of each type from 00 to n−1n - 1.

In one operation, you can pay a cost of x to rotate the chocolates circularly such that the chocolate originally of type i can now be collected at the cost of nums[(i + 1) % n]. You can perform this operation any number of times.

Return the minimum total cost needed to collect all nn types of chocolates.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq x ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Collecting Chocolates

Try to solve the Collecting Chocolates problem.

Statement

You are given a 00 indexed integer array nums of length nn representing the initial cost of collecting chocolates of types 00 to n−1n - 1, where nums[i] denotes the cost of collecting a chocolate of type i.

You want to collect at least one chocolate of each type from 00 to n−1n - 1.

In one operation, you can pay a cost of x to rotate the chocolates circularly such that the chocolate originally of type i can now be collected at the cost of nums[(i + 1) % n]. You can perform this operation any number of times.

Return the minimum total cost needed to collect all nn types of chocolates.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq x ≤109\leq 10^9