FPEvalDataset/LeetCodeProblem
0305
1{2 "id": 2917,3 "name": "count_pairs_whose_sum_is_less_than_target",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/count-pairs-whose-sum-is-less-than-target/",6 "date": "1691193600000",7 "task_description": "Given a **0-indexed** integer array `nums` of length `n` and an integer `target`, return _the number of pairs_ `(i, j)` _where_ `0 <= i < j < n` _and_ `nums[i] + nums[j] < target`. **Example 1:** ``` **Input:** nums = [-1,1,2,3,1], target = 2 **Output:** 3 **Explanation:** There are 3 pairs of indices that satisfy the conditions in the statement: - (0, 1) since 0 < 1 and nums[0] + nums[1] = 0 < target - (0, 2) since 0 < 2 and nums[0] + nums[2] = 1 < target - (0, 4) since 0 < 4 and nums[0] + nums[4] = 0 < target Note that (0, 3) is not counted since nums[0] + nums[3] is not strictly less than the target. ``` **Example 2:** ``` **Input:** nums = [-6,2,5,-2,-7,-1,3], target = -2 **Output:** 10 **Explanation:** There are 10 pairs of indices that satisfy the conditions in the statement: - (0, 1) since 0 < 1 and nums[0] + nums[1] = -4 < target - (0, 3) since 0 < 3 and nums[0] + nums[3] = -8 < target - (0, 4) since 0 < 4 and nums[0] + nums[4] = -13 < target - (0, 5) since 0 < 5 and nums[0] + nums[5] = -7 < target - (0, 6) since 0 < 6 and nums[0] + nums[6] = -3 < target - (1, 4) since 1 < 4 and nums[1] + nums[4] = -5 < target - (3, 4) since 3 < 4 and nums[3] + nums[4] = -9 < target - (3, 5) since 3 < 5 and nums[3] + nums[5] = -3 < target - (4, 5) since 4 < 5 and nums[4] + nums[5] = -8 < target - (4, 6) since 4 < 6 and nums[4] + nums[6] = -4 < target ``` **Constraints:** `1 <= nums.length == n <= 50` `-50 <= nums[i], target <= 50`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "nums = [-1,1,2,3,1], target = 2",12 "output": "3 "13 },14 {15 "label": "Example 2",16 "input": "nums = [-6,2,5,-2,-7,-1,3], target = -2",17 "output": "10 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 [24 -47,25 -2,26 18,27 3128 ],29 4630 ],31 "output": 532 },33 {34 "input": [35 [36 -18,37 -13,38 14,39 28,40 34,41 5042 ],43 -3944 ],45 "output": 046 },47 {48 "input": [49 [50 -27,51 -6,52 19,53 42,54 4355 ],56 657 ],58 "output": 259 },60 {61 "input": [62 [63 -48,64 -29,65 -22,66 35,67 4668 ],69 -4970 ],71 "output": 372 },73 {74 "input": [75 [76 -40,77 -35,78 -31,79 -30,80 -29,81 -27,82 -25,83 -24,84 -22,85 -21,86 -12,87 -9,88 -5,89 -2,90 8,91 9,92 10,93 17,94 27,95 31,96 35,97 38,98 43,99 49100 ],101 3102 ],103 "output": 152104 },105 {106 "input": [107 [108 -48,109 -44,110 -43,111 -40,112 -36,113 -30,114 -29,115 -29,116 -29,117 -26,118 -22,119 -22,120 -18,121 -18,122 -18,123 -17,124 -14,125 -6,126 -5,127 -5,128 -4,129 -2,130 -2,131 3,132 5,133 7,134 7,135 9,136 11,137 14,138 16,139 17,140 25,141 25,142 27,143 28,144 31,145 32,146 33,147 38,148 45,149 48150 ],151 -35152 ],153 "output": 175154 },155 {156 "input": [157 [158 -50,159 -47,160 -43,161 -43,162 -36,163 -32,164 -32,165 -28,166 -26,167 -23,168 -16,169 -3,170 8,171 12,172 17,173 28,174 28,175 36,176 37,177 37,178 48179 ],180 -18181 ],182 "output": 90183 },184 {185 "input": [186 [187 -50,188 -50,189 -38,190 -34,191 -32,192 -30,193 -21,194 -12,195 -7,196 2,197 6,198 27199 ],200 1201 ],202 "output": 60203 },204 {205 "input": [206 [207 -45,208 -36,209 -26,210 -21,211 -20,212 -8,213 -6,214 -6,215 -3,216 7,217 7,218 9,219 11,220 11,221 13,222 14,223 25,224 35,225 37,226 39,227 40,228 40,229 41,230 45,231 49,232 49233 ],234 -16235 ],236 "output": 48237 },238 {239 "input": [240 [241 -28,242 -27,243 -20,244 -18,245 -16,246 -10,247 11,248 13,249 16,250 17,251 19,252 21,253 21,254 33255 ],256 -6257 ],258 "output": 30259 }260 ],261 "haskell_template": "countPairs :: [Int] -> Int -> Int\ncountPairs nums target ",262 "ocaml_template": "let countPairs (nums: int list) (target: int) : int = ",263 "scala_template": "def countPairs(nums: List[Int],target: Int): Int = { \n \n}",264 "java_template": "public static int countPairs(List<Integer> nums, int target) {\n\n}",265 "python_template": "class Solution(object):\n def countPairs(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: int\n \"\"\"\n "266}