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

歡迎光臨散文網(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ó)家法律
隆子县| 阜平县| 秦皇岛市| 科技| 德清县| 奉节县| 探索| 内黄县| 高青县| 汶上县| 交城县| 棋牌| 漯河市| 漳平市| 油尖旺区| 金塔县| 镇安县| 个旧市| 河池市| 长岛县| 句容市| 三都| 开阳县| 东明县| 北宁市| 道孚县| 南昌县| 凉山| 灯塔市| 柘城县| 石景山区| 得荣县| 木兰县| 酒泉市| 左云县| 靖安县| 朝阳县| 惠州市| 高雄市| 涡阳县| 烟台市|