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

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

LeetCode 1497. Check If Array Pairs Are Divisible by k

2023-05-04 15:03 作者:您是打尖兒還是住店呢  | 我要投稿

iven an array of integers?arr?of even length?n?and an integer?k.

We want to divide the array into exactly?n / 2?pairs such that the sum of each pair is divisible by?k.

Return?true?If you can find a way to do that or?false?otherwise.

?

Example 1:

Input: arr = [1,2,3,4,5,10,6,7,8,9], k = 5

Output: true

Explanation: Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).

Example 2:

Input: arr = [1,2,3,4,5,6], k = 7

Output: true

Explanation: Pairs are (1,6),(2,5) and(3,4).

Example 3:

Input: arr = [1,2,3,4,5,6], k = 10

Output: false

Explanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10.

?

Constraints:

  • arr.length == n

  • 1 <= n <= 105

  • n?is even.

  • -109?<= arr[i] <= 109

  • 1 <= k <= 105

我用hashmap總不過,真的想不出來是什么原因,因?yàn)槭窃跀?shù)據(jù)集很大的時(shí)候不過的,

沒辦法就換成數(shù)組了,秒過。。。。

Runtime:?5 ms, faster than?96.99%?of?Java?online submissions for?Check If Array Pairs Are Divisible by k.

Memory Usage:?50.3 MB, less than?85.24%?of?Java?online submissions for?Check If Array Pairs Are Divisible by k.


LeetCode 1497. Check If Array Pairs Are Divisible by k的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
普定县| 赤壁市| 蓬溪县| 图们市| 元谋县| 汝州市| 灵石县| 永寿县| 张家界市| 宿迁市| 澳门| 田林县| 尼勒克县| 孟村| 宁远县| 合作市| 巨鹿县| 莆田市| 枝江市| 沛县| 措美县| 桂阳县| 武山县| 建始县| 武威市| 隆尧县| 灵川县| 平塘县| 南昌县| 疏附县| 绥中县| 南阳市| 渭南市| 读书| 开封市| 通州市| 景东| 射阳县| 齐齐哈尔市| 德保县| 阿尔山市|