| about | help | code help+videos | done | prefs |
Given an int[] and a target value, return the number of all unique index pairs [i, j] where arr[i] + arr[j] == target and i < j. e.g. twoSumPairs(new int[]{2,7,4,1,3}, 5) has two valid pairs: index 0 and index 4, as well as index 2 and index 3. It will return 2. Use a single loop to achieve O(n) time. twoSumPairs([], 7) → 0 twoSumPairs([2, 7, 4, 1, 3], 5) → 2 twoSumPairs([3, 3], 6) → 1 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy