package com.fishercoder.solutions;

import java.util.HashMap;
import java.util.Map;

public class _1711 {
    public static class Solution1 {
        private static final long MODUALR = 1000000007;

        public int countPairs(int[] deliciousness) {
            Map<Integer, Integer> map = new HashMap<>();
            long pairs = 0;
            for (int i = 0; i < deliciousness.length; i++) {
                int power = 1;
                for (int j = 0; j < 22; j++) {//we only need to go up to 21 since one of the constraints is: 0 <= deliciousness[i] <= 2 to the power of 20
                    if (map.containsKey(power - deliciousness[i])) {
                        pairs += map.get(power - deliciousness[i]);
                        pairs %= MODUALR;
                    }
                    power *= 2;
                }
                map.put(deliciousness[i], map.getOrDefault(deliciousness[i], 0) + 1);
            }
            return (int) pairs;
        }

    }
}

@@ -442,38 +442,8 @@
     
-for (int j = 0; j %3C 22; j++) %7B
 //we
@@ -547,16 +547,63 @@
 r of 20%0A
+                for (int j = 0; j %3C 22; j++) %7B%0A
         

fix build