无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

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

LeetCode 2451. Odd String Difference

2023-01-07 16:48 作者:您是打尖兒還是住店呢  | 我要投稿

You are given an array of equal-length strings?words. Assume that the length of each string is?n.

Each string?words[i]?can be converted into a?difference integer array?difference[i]?of length?n - 1?where?difference[i][j] = words[i][j+1] - words[i][j]?where?0 <= j <= n - 2. Note that the difference between two letters is the difference between their?positions?in the alphabet i.e.?the position of?'a'?is?0,?'b'?is?1, and?'z'?is?25.

  • For example, for the string?"acb", the difference integer array is?[2 - 0, 1 - 2] = [2, -1].

All the strings in words have the same difference integer array,?except one. You should find that string.

Return?the string in?words?that has different?difference integer array.

?

Example 1:

Input: words = ["adc","wzy","abc"]Output: "abc"Explanation: - The difference integer array of "adc" is [3 - 0, 2 - 3] = [3, -1]. - The difference integer array of "wzy" is [25 - 22, 24 - 25]= [3, -1]. - The difference integer array of "abc" is [1 - 0, 2 - 1] = [1, 1]. The odd array out is [1, 1], so we return the corresponding string, "abc".

Example 2:

Input: words = ["aaa","bob","ccc","ddd"]Output: "bob"Explanation: All the integer arrays are [0, 0] except for "bob", which corresponds to [13, -13].

?

Constraints:

  • 3 <= words.length <= 100

  • n == words[i].length

  • 2 <= n <= 20

  • words[i]?consists of lowercase English letters.

hashmap可以做list跟string的映射,之前都沒(méi)有試過(guò),第一次嘗試,用起來(lái)還可以,如果這樣的話,

可以判斷重復(fù)的list,

Runtime3 ms

Beats

60.75%

Memory39.9 MB

Beats

93.18%


LeetCode 2451. Odd String Difference的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
肃北| 临武县| 盐亭县| 文登市| 壤塘县| 罗城| 琼海市| 二连浩特市| 蕉岭县| 岱山县| 桂东县| 海丰县| 隆尧县| 孟州市| 庆元县| 五常市| 长阳| 桐梓县| 科技| 饶平县| 南江县| 监利县| 轮台县| 桓台县| 上林县| 肇源县| 县级市| 凉城县| 美姑县| 肃宁县| 惠州市| 汪清县| 翼城县| 松江区| 葫芦岛市| 金坛市| 集安市| 巴林右旗| 滨海县| 五大连池市| 民和|