Tap here to switch tabs
Problem
Submissions

Problem: Count Good Meals

med
30 min
Try to solve the Count Good Meals problem.

Statement

A meal is defined as a good meal if it consists of exactly two different food items whose sum of deliciousness values equals a power of 22 (that is, 2k2^k for some non negative integer kk).

Given an integer array deliciousness, where deliciousness[i] represents the deliciousness value of the food item at index i, return the total number of distinct pairs that form a good meal modulo 109+710^9 + 7.

Note: Pairs with different index combinations are considered distinct even if the corresponding food items have identical deliciousness values.

Constraints:

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

  • 0≤0 \leq deliciousness[i] ≤220\leq 2^{20}

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Good Meals

med
30 min
Try to solve the Count Good Meals problem.

Statement

A meal is defined as a good meal if it consists of exactly two different food items whose sum of deliciousness values equals a power of 22 (that is, 2k2^k for some non negative integer kk).

Given an integer array deliciousness, where deliciousness[i] represents the deliciousness value of the food item at index i, return the total number of distinct pairs that form a good meal modulo 109+710^9 + 7.

Note: Pairs with different index combinations are considered distinct even if the corresponding food items have identical deliciousness values.

Constraints:

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

  • 0≤0 \leq deliciousness[i] ≤220\leq 2^{20}