Tap here to switch tabs
Problem
Submissions

Problem: Find the Maximum Number of Marked Indices

Find the Maximum Number of Marked Indices asks you to pair distinct unmarked array indices so one value is at least twice the other, then return the largest possible number of marked indices.

Statement

You are given a 00 indexed integer array nums.

Initially, all indices are unmarked. You can perform the following operation any number of times:

  • Pick two distinct unmarked indices i and j such that 2imes2 imes nums[i] ≤\leq nums[j].

  • Mark both index i and index j.

Return the maximum possible number of marked indices after performing the operation optimally.

Constraints:

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Maximum Number of Marked Indices

Find the Maximum Number of Marked Indices asks you to pair distinct unmarked array indices so one value is at least twice the other, then return the largest possible number of marked indices.

Statement

You are given a 00 indexed integer array nums.

Initially, all indices are unmarked. You can perform the following operation any number of times:

  • Pick two distinct unmarked indices i and j such that 2imes2 imes nums[i] ≤\leq nums[j].

  • Mark both index i and index j.

Return the maximum possible number of marked indices after performing the operation optimally.

Constraints:

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

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