Tap here to switch tabs
Problem
Submissions

Problem: Successful Pairs of Spells and Potions

Try to solve the Successful Pairs of Spells and Potions problem.

Statement

You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the iextthi^{ ext{th}} spell and potions[j] represents the strength of the jextthj^{ ext{th}} potion.

You are also given an integer success. A spell and potion pair is considered successful if the product of their strengths is at least success.

Return an integer array pairs of length n where pairs[i] is the number of potions that will form a successful pair with the iextthi^{ ext{th}} spell.

Constraints:

  • n ==== spells.length

  • m ==== potions.length

  • 1≤1 \leq n, m ≤105\leq 10^5

  • 1≤1 \leq spells[i], potions[i] ≤105\leq 10^5

  • 1≤1 \leq success ≤1010\leq 10^{10}

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Successful Pairs of Spells and Potions

Try to solve the Successful Pairs of Spells and Potions problem.

Statement

You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the iextthi^{ ext{th}} spell and potions[j] represents the strength of the jextthj^{ ext{th}} potion.

You are also given an integer success. A spell and potion pair is considered successful if the product of their strengths is at least success.

Return an integer array pairs of length n where pairs[i] is the number of potions that will form a successful pair with the iextthi^{ ext{th}} spell.

Constraints:

  • n ==== spells.length

  • m ==== potions.length

  • 1≤1 \leq n, m ≤105\leq 10^5

  • 1≤1 \leq spells[i], potions[i] ≤105\leq 10^5

  • 1≤1 \leq success ≤1010\leq 10^{10}