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

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

leetcode791. Custom Sort String

2022-03-24 10:58 作者:您是打尖兒還是住店呢  | 我要投稿

You are given two strings order and s. All the words of?order?are?unique?and were sorted in some custom order previously.

Permute the characters of?s?so that they match the order that?order?was sorted. More specifically, if a character?x?occurs before a character?y?in?order, then?x?should occur before?y?in the permuted string.

Return?any permutation of?s?that satisfies this property.

?

Example 1:

Input: order = "cba", s = "abcd"Output: "cbad"Explanation: "a", "b", "c" appear in order, so the order of "a", "b", "c" should be "c", "b", and "a". Since "d" does not appear in order, it can be at any position in the returned string. "dcba", "cdba", "cbda" are also valid outputs.

Example 2:

Input: order = "cbafg", s = "abcd"Output: "cbad"

?

Constraints:

  • 1 <= order.length <= 26

  • 1 <= s.length <= 200

  • order?and?s?consist of lowercase English letters.

  • All the characters of?order?are?unique.

先將字符串變成字符數(shù)組,然后根據(jù)排序的字符串依次append,就可以了,挺好的。


Runtime:?0 ms, faster than?100.00%?of?Java?online submissions for?Custom Sort String.

Memory Usage:?40 MB, less than?89.76%?of?Java?online submissions for?Custom Sort String.


leetcode791. Custom Sort String的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
阳东县| 响水县| 屏南县| 华宁县| 龙州县| 建水县| 易门县| 巴塘县| 钟山县| 新龙县| 慈利县| 江城| 宜阳县| 鄂伦春自治旗| 北碚区| 峡江县| 托克逊县| 汝阳县| 金溪县| 吉木乃县| 上饶市| 河池市| 冷水江市| 武冈市| 柳江县| 罗田县| 永定县| 兴文县| 治县。| 武城县| 宝山区| 莱西市| 鄄城县| 新巴尔虎右旗| 彭阳县| 和田县| 洪洞县| 江油市| 商都县| 元谋县| 镇江市|