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

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

Leetcode 1003. Check If Word Is Valid After Substitutions

2023-03-01 09:27 作者:您是打尖兒還是住店呢  | 我要投稿

Given a string?s, determine if it is?valid.

A string?s?is?valid?if, starting with an empty string?t = "", you can?transform?t?into?s?after performing the following operation?any number of times:

  • Insert string?"abc"?into any position in?t. More formally,?t?becomes?tleft?+ "abc" + tright, where?t == tleft?+ tright. Note that?tleft?and?tright?may be?empty.

Return?true?if?s?is a?valid?string, otherwise, return?false.

?

Example 1:

Input: s = "aabcbc"Output: trueExplanation:"" -> "abc" -> "aabcbc" Thus, "aabcbc" is valid.

Example 2:

Input: s = "abcabcababcc"Output: trueExplanation:"" -> "abc" -> "abcabc" -> "abcabcabc" -> "abcabcababcc" Thus, "abcabcababcc" is valid.

Example 3:

Input: s = "abccba"Output: falseExplanation: It is impossible to get "abccba" using the operation.

?

Constraints:

  • 1 <= s.length <= 2 * 104

  • s?consists of letters?'a',?'b', and?'c'

能過(guò)就行,不強(qiáng)求了。



Runtime:?635 ms, faster than?5.13%?of?Java?online submissions for?Check If Word Is Valid After Substitutions.

Memory Usage:?43 MB, less than?21.79%?of?Java?online submissions for?Check If Word Is Valid After Substitutions.


Leetcode 1003. Check If Word Is Valid After Substitutions的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
盐边县| 萨迦县| 杭锦旗| 巴彦淖尔市| 灵山县| 建瓯市| 县级市| 唐山市| 洛阳市| 东海县| 勐海县| 微博| 靖安县| 伊川县| 淮安市| 巴南区| 沈阳市| 喜德县| 哈密市| 安图县| 苍山县| 洪湖市| 揭西县| 临颍县| 揭阳市| 张家界市| 涞源县| 赤城县| 嘉荫县| 东乌珠穆沁旗| 宜丰县| 七台河市| 南宫市| 堆龙德庆县| 福贡县| 宜君县| 安溪县| 东山县| 沈阳市| 大丰市| 泗阳县|