Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Integers to Choose from a Range I

Maximum Number of Integers to Choose from a Range I asks you to choose distinct integers from one through n, avoiding values listed in banned, and return the largest count whose total does not exceed the given sum limit.

Statement

Given an integer array banned and two integers n and max_sum, determine the maximum number of integers you can choose while adhering to the following rules:

  1. The selected integers must fall within the range [1,n][1, n].

  2. Each integer can be chosen at most once.

  3. No selected integer can be present in the banned array.

  4. The sum of the selected integers must not exceed max_sum.

Your goal is to return the maximum count of integers that can be chosen while satisfying all the above constraints.

Constraints:

  • 1≤1 \leq banned.length ≤103\leq 10^3

  • 1≤1 \leq banned[i], n ≤103\leq 10^3

  • 1≤1 \leq max_sum ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Integers to Choose from a Range I

Maximum Number of Integers to Choose from a Range I asks you to choose distinct integers from one through n, avoiding values listed in banned, and return the largest count whose total does not exceed the given sum limit.

Statement

Given an integer array banned and two integers n and max_sum, determine the maximum number of integers you can choose while adhering to the following rules:

  1. The selected integers must fall within the range [1,n][1, n].

  2. Each integer can be chosen at most once.

  3. No selected integer can be present in the banned array.

  4. The sum of the selected integers must not exceed max_sum.

Your goal is to return the maximum count of integers that can be chosen while satisfying all the above constraints.

Constraints:

  • 1≤1 \leq banned.length ≤103\leq 10^3

  • 1≤1 \leq banned[i], n ≤103\leq 10^3

  • 1≤1 \leq max_sum ≤106\leq 10^6