Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Collect Elements

Try to solve the Minimum Operations to Collect Elements problem.

Statement

You are given an array nums of positive integers and an integer k.

In one operation, you can remove the last element of the array and add it to your collection.

Return the minimum number of operations required to collect all integers from 11 to k.

Constraints:

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

  • 1≤1 \leq nums[i] ≤\leq nums.length

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

  • The input is generated such that you can collect elements 1,2,…,1, 2, \dots, k.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Collect Elements

Try to solve the Minimum Operations to Collect Elements problem.

Statement

You are given an array nums of positive integers and an integer k.

In one operation, you can remove the last element of the array and add it to your collection.

Return the minimum number of operations required to collect all integers from 11 to k.

Constraints:

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

  • 1≤1 \leq nums[i] ≤\leq nums.length

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

  • The input is generated such that you can collect elements 1,2,…,1, 2, \dots, k.