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

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
逊克县| 河北省| 内黄县| 化德县| 平江县| 西峡县| 四平市| 承德县| 龙南县| 新宁县| 昌都县| 保山市| 墨玉县| 延庆县| 华宁县| 涞水县| 普宁市| 宁化县| 北辰区| 虎林市| 三亚市| 彰化县| 东乌珠穆沁旗| 罗源县| 通江县| 财经| 韶关市| 雅江县| 静宁县| 启东市| 雷波县| 东至县| 大宁县| 灵台县| 财经| 桑植县| 曲水县| 漳平市| 焉耆| 高淳县| 峨眉山市|