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

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

LeetCode 2825. Make String a Subsequence Using Cyclic Increments

2023-08-20 08:58 作者:您是打尖兒還是住店呢  | 我要投稿

You are given two 0-indexed strings str1 and str2.


In an operation, you select a set of indices in str1, and for each index i in the set, increment str1[i] to the next character cyclically. That is 'a' becomes 'b', 'b' becomes 'c', and so on, and 'z' becomes 'a'.


Return true if it is possible to make str2 a subsequence of str1 by performing the operation at most once, and false otherwise.


Note: A subsequence of a string is a new string that is formed from the original string by deleting some (possibly none) of the characters without disturbing the relative positions of the remaining characters.

-----------------------------------------


給定兩個 0 索引的字符串 str1 和 str2。


在操作中,您在 str1 中選擇一組索引,并且對于該組中的每個索引 i,將 str1[i] 循環(huán)遞增到下一個字符。 即“a”變?yōu)椤癰”,“b”變?yōu)椤癱”,依此類推,“z”變?yōu)椤癮”。


如果最多執(zhí)行一次操作可以使 str2 成為 str1 的子序列,則返回 true,否則返回 false。


注意:字符串的子序列是通過刪除一些(可能沒有)字符而不影響剩余字符的相對位置而從原始字符串形成的新字符串。

利用雙指針做法即可;最后判斷str2的指針是否等于字符串的長度;


Runtime:?7 ms, faster than?100.00%?of?Java?online submissions for?Make String a Subsequence Using Cyclic Increments.

Memory Usage:?44.5 MB, less than?100.00%?of?Java?online submissions for?Make String a Subsequence Using Cyclic Increments.


LeetCode 2825. Make String a Subsequence Using Cyclic Increments的評論 (共 條)

分享到微博請遵守國家法律
隆子县| 密云县| 英吉沙县| 九江县| 镇远县| 永靖县| 保亭| 临洮县| 皋兰县| 昂仁县| 淳安县| 喀喇沁旗| 读书| 浦县| 呼和浩特市| 崇义县| 双鸭山市| 敖汉旗| 剑川县| 无棣县| 扎兰屯市| 襄垣县| 六枝特区| 桐城市| 新平| 韶关市| 五寨县| 壤塘县| 敦化市| 长武县| 武夷山市| 昭苏县| 五莲县| 专栏| 原阳县| 高台县| 文登市| 华安县| 遵义县| 斗六市| 繁昌县|