最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

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

Leetcode2053. Kth Distinct String in an Array

2022-02-02 15:54 作者:您是打尖兒還是住店呢  | 我要投稿

A?distinct string?is a string that is present only?once?in an array.

Given an array of strings?arr, and an integer?k, return?the?kth?distinct string?present in?arr. If there are?fewer?than?k?distinct strings, return?an?empty string?"".

Note that the strings are considered in the?order in which they appear?in the array.

?

Example 1:

Input: arr = ["d","b","c","b","c","a"], k = 2Output: "a"Explanation:The only distinct strings in arr are "d" and "a". "d" appears 1st, so it is the 1st distinct string. "a" appears 2nd, so it is the 2nd distinct string. Since k == 2, "a" is returned.

Example 2:

Input: arr = ["aaa","aa","a"], k = 1Output: "aaa"Explanation:All strings in arr are distinct, so the 1st string "aaa" is returned.

Example 3:

Input: arr = ["a","b","a"], k = 3Output: ""Explanation:The only distinct string is "b". Since there are fewer than 3 distinct strings, we return an empty string "".

?

Constraints:

  • 1 <= k <= arr.length <= 1000

  • 1 <= arr[i].length <= 5

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


Runtime:?8 ms, faster than?52.92%?of?Java?online submissions for?Kth Distinct String in an Array.

Memory Usage:?45.2 MB, less than?5.48%?of?Java?online submissions for?Kth Distinct String in an Array.


Leetcode2053. Kth Distinct String in an Array的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
武义县| 元朗区| 塘沽区| 耿马| 顺昌县| 临高县| 永登县| 霍州市| 大丰市| 海安县| 漳州市| 胶州市| 修武县| 江都市| 普兰县| 丹寨县| 商丘市| 晋城| 镇雄县| 东兰县| 句容市| 和田市| 安仁县| 旅游| 荥阳市| 米泉市| 公安县| 汉源县| 浮山县| 尚志市| 贵州省| 抚顺市| 惠州市| 吉隆县| 桦川县| 化德县| 长泰县| 昔阳县| 个旧市| 高州市| 西畴县|