FastPrepProfitable Project Pairs
Problems/Profitable Project Pairs

Profitable Project Pairs

Akuna Capital logoAkuna Capital● MediumINTERNOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: 🐿️ This practice version is about a 98% match to the available source. The profitable-pair definition, strict combined net-profit condition, function contract, worked example, and numeric bounds come directly from the source. The source image is visually degraded, so the wording was cleaned up for readability without changing what the original question asks you to do.

A team can choose any two distinct projects from n available projects.

For project i:

  • profit[i] is its expected profit.
  • implementationCost[i] is its implementation cost.

A pair of projects (i, j), where 0 <= i < j < n, is profitable when:

(profit[i] - implementationCost[i]) + (profit[j] - implementationCost[j]) > 0

Return the number of profitable project pairs.

Complete the function getProfitablePairs, which accepts the arrays profit and implementationCost and returns the required count.

Function

getProfitablePairs(profit: int[], implementationCost: int[]) → long

Examples

Example 1

profit = [2, 3, 7, 1, 1]implementationCost = [3, 4, 5, 1, 2]return = 4

The net profits are [-1, -1, 2, 0, -1].

The profitable pairs are:

  • (0, 2): -1 + 2 = 1
  • (1, 2): -1 + 2 = 1
  • (2, 3): 2 + 0 = 2
  • (2, 4): 2 + (-1) = 1

No other pair has a positive combined net profit, so the result is 4.

Constraints

  • 1 <= n <= 2 * 10^5
  • profit.length = implementationCost.length = n
  • 1 <= profit[i], implementationCost[i] <= 10^9

More Akuna Capital problems

  • Delivery Management SystemOA · Seen Nov 2026
  • Count Server ReplacementsOA · Seen Nov 2026
  • Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
All Akuna Capital interview questionsSee Akuna Capital hiring insights
Saved
class Solution {
    public long getProfitablePairs(int[] profit, int[] implementationCost) {
      // Write your code here.
    }

}
Checking account…