Tap here to switch tabs
Problem
Submissions

Problem: Minimize Array After Replacing Pairs With Products

Try to solve the Minimize Array After Replacing Pairs With Products problem.

Statement

You are given an integer array nums and an integer k.

In one operation, you can choose two adjacent elements in nums whose product is less than or equal to k, and replace them with a single element equal to their product.

Return the minimum possible length of nums after performing any number of operations.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimize Array After Replacing Pairs With Products

Try to solve the Minimize Array After Replacing Pairs With Products problem.

Statement

You are given an integer array nums and an integer k.

In one operation, you can choose two adjacent elements in nums whose product is less than or equal to k, and replace them with a single element equal to their product.

Return the minimum possible length of nums after performing any number of operations.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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

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