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

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

leetcode748. Shortest Completing Word

2022-03-16 14:40 作者:您是打尖兒還是住店呢  | 我要投稿

Given a string?licensePlate?and an array of strings?words, find the?shortest completing?word in?words.

A?completing?word is a word that?contains all the letters?in?licensePlate.?Ignore numbers and spaces?in?licensePlate, and treat letters as?case insensitive. If a letter appears more than once in?licensePlate, then it must appear in the word the same number of times or more.

For example, if?licensePlate?= "aBc 12c", then it contains letters?'a',?'b'?(ignoring case), and?'c'?twice. Possible?completing?words are?"abccdef",?"caaacab", and?"cbca".

Return?the shortest?completing?word in?words.?It is guaranteed an answer exists. If there are multiple shortest?completing?words, return the?first?one that occurs in?words.

?

Example 1:

Input: licensePlate = "1s3 PSt", words = ["step","steps","stripe","stepple"]Output: "steps"Explanation: licensePlate contains letters 's', 'p', 's' (ignoring case), and 't'. "step" contains 't' and 'p', but only contains 1 's'. "steps" contains 't', 'p', and both 's' characters. "stripe" is missing an 's'. "stepple" is missing an 's'. Since "steps" is the only word containing all the letters, that is the answer.

Example 2:

Input: licensePlate = "1s3 456", words = ["looks","pest","stew","show"]Output: "pest"Explanation: licensePlate only contains the letter 's'. All the words contain 's', but among these "pest", "stew", and "show" are shortest. The answer is "pest" because it is the word that appears earliest of the 3.

?

Constraints:

  • 1 <= licensePlate.length <= 7

  • licensePlate?contains digits, letters (uppercase or lowercase), or space?' '.

  • 1 <= words.length <= 1000

  • 1 <= words[i].length <= 15

  • words[i]?consists of lower case English letters.

    就是找到字符串?dāng)?shù)組中,包含對應(yīng)字符以及數(shù)量的最短的字符串;

Runtime:?2 ms, faster than?98.51%?of?Java?online submissions for?Shortest Completing Word.

Memory Usage:?42.4 MB, less than?89.36%?of?Java?online submissions for?Shortest Completing Word.


leetcode748. Shortest Completing Word的評論 (共 條)

分享到微博請遵守國家法律
河北省| 衡水市| 五原县| 馆陶县| 海口市| 淮滨县| 永泰县| 射洪县| 缙云县| 三都| 屏南县| 宁城县| 准格尔旗| 宁都县| 尼勒克县| 仁化县| 射阳县| 华坪县| 江都市| 大余县| 旬阳县| 东宁县| 玉溪市| 黄骅市| 芷江| 松溪县| 施甸县| 灵璧县| 简阳市| 景东| 桐城市| 昆明市| 报价| 怀化市| 加查县| 大宁县| 荔浦县| 叶城县| 南皮县| 望谟县| 哈巴河县|