国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

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

LeetCode 1128. Number of Equivalent Domino Pairs

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

Given a list of?dominoes,?dominoes[i] = [a, b]?is?equivalent to?dominoes[j] = [c, d]?if and only if either (a == c?and?b == d), or (a == d?and?b == c) - that is, one domino can be rotated to be equal to another domino.

Return?the number of pairs?(i, j)?for which?0 <= i < j < dominoes.length, and?dominoes[i]?is?equivalent to?dominoes[j].

?

Example 1:

Input: dominoes = [[1,2],[2,1],[3,4],[5,6]]

Output: 1

Example 2:

Input: dominoes = [[1,2],[1,2],[1,1],[1,2],[2,2]]

Output: 3

?

Constraints:

  • 1 <= dominoes.length <= 4 * 104

  • dominoes[i].length == 2

  • 1 <= dominoes[i][j] <= 9

找到相同組合的個數(shù),2,3 跟3,2是一樣的,所以我們就用大小順序放在一起組成字符串,作為hashmap的key,放進(jìn)去,最后一次遍歷value>1 的情況,即可;

下面是代碼:

Runtime:?24 ms, faster than?39.74%?of?Java?online submissions for?Number of Equivalent Domino Pairs.

Memory Usage:?52.4 MB, less than?38.03%?of?Java?online submissions for?Number of Equivalent Domino Pairs.


LeetCode 1128. Number of Equivalent Domino Pairs的評論 (共 條)

分享到微博請遵守國家法律
门源| 广水市| 驻马店市| 阜宁县| 博罗县| 洮南市| 东光县| 安西县| 伊川县| 翁牛特旗| 英吉沙县| 仲巴县| 汉中市| 衢州市| 略阳县| 新宾| 湖南省| 龙山县| 星子县| 自治县| 靖西县| 佛山市| 乳山市| 密山市| 神池县| 盈江县| 米易县| 万州区| 叶城县| 修水县| 宁武县| 临泽县| 定西市| 宁夏| 吕梁市| 睢宁县| 年辖:市辖区| 杂多县| 嘉善县| 浦北县| 积石山|