五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

LeetCode 2824. Count Pairs Whose Sum is Less than Target

2023-08-20 08:14 作者:您是打尖兒還是住店呢  | 我要投稿

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



Runtime:?2 ms, faster than?100.00%?of?Java?online submissions for?Count Pairs Whose Sum is Less than Target.

Memory Usage:?41.5 MB, less than?50.00%?of?Java?online submissions for?Count Pairs Whose Sum is Less than Target.


LeetCode 2824. Count Pairs Whose Sum is Less than Target的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
冷水江市| 海口市| 大理市| 石屏县| 康定县| 保康县| 阳信县| 武宣县| 石首市| 炎陵县| 上饶县| 林芝县| 鸡泽县| 石屏县| 百色市| 台州市| 平乡县| 拜泉县| 莱西市| 桃园市| 大庆市| 出国| 商城县| 盐山县| 霍邱县| 通海县| 宁阳县| 察隅县| 瓦房店市| 廉江市| 巴林左旗| 福鼎市| 富民县| 普陀区| 桐庐县| 鹤山市| 邮箱| 河池市| 涞源县| 隆子县| 神池县|