Tap here to switch tabs
Problem
Submissions

Problem: Maximize Consecutive Elements After Array Modification

Try to solve the Maximize Consecutive Elements in an Array After Modification problem.

Statement

You are given an integer array nums.

You can increase the value of any element in nums by at most 11. Each element can be modified at most once.

After applying any number of these operations, select a collection of elements from the resulting array such that they form a sequence of consecutive integers when sorted in ascending order.

Return the maximum number of elements you can select.

Constraints:

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

  • 1≤1 \leq nums[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximize Consecutive Elements After Array Modification

Try to solve the Maximize Consecutive Elements in an Array After Modification problem.

Statement

You are given an integer array nums.

You can increase the value of any element in nums by at most 11. Each element can be modified at most once.

After applying any number of these operations, select a collection of elements from the resulting array such that they form a sequence of consecutive integers when sorted in ascending order.

Return the maximum number of elements you can select.

Constraints:

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

  • 1≤1 \leq nums[i] ≤106\leq 10^6