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

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

LeetCode 2730. Find the Longest Semi-Repetitive Substring

2023-06-11 15:15 作者:您是打尖兒還是住店呢  | 我要投稿

You are given a?0-indexed?string?s?that consists of digits from?0?to?9.

A string?t?is called a?semi-repetitive?if there is at most one consecutive pair of the same digits inside?t. For example,?0010,?002020,?0123,?2002, and?54944?are semi-repetitive while?00101022, and?1101234883?are not.

Return?the length of the longest semi-repetitive substring inside?s.

A?substring?is a contiguous?non-empty?sequence of characters within a string.

?

Example 1:

Input: s = "52233"Output: 4

Explanation: The longest semi-repetitive substring is "5223", which starts at i = 0 and ends at j = 3.

Example 2:

Input: s = "5494"Output: 4

Explanation: s is a semi-reptitive string, so the answer is 4.

Example 3:

Input: s = "1111111"Output: 2

Explanation: The longest semi-repetitive substring is "11", which starts at i = 0 and ends at j = 1.

?

Constraints:

  • 1 <= s.length <= 50

  • '0' <= s[i] <= '9'

sliding window也可以做,老是沒想出來解法,先用暴力做了;

下面是代碼:

Runtime:?56 ms, faster than?50.00%?of?Java?online submissions for?Find the Longest Semi-Repetitive Substring.

?Memory Usage:is?44 MB, less than?50.00%?of?Java?online submissions for?Find the Longest Semi-Repetitive Substring.


LeetCode 2730. Find the Longest Semi-Repetitive Substring的評論 (共 條)

分享到微博請遵守國家法律
宁乡县| 金山区| 垣曲县| 本溪市| 揭东县| 黄骅市| 封丘县| 永胜县| 漾濞| 土默特左旗| 新蔡县| 凤翔县| 临泉县| 方正县| 历史| 岢岚县| 滕州市| 牙克石市| 淮北市| 彩票| 历史| 东光县| 德安县| 临江市| 开原市| 凉城县| 彰武县| 宝坻区| 雷州市| 长兴县| 西昌市| 龙里县| 南昌市| 沙雅县| 兴文县| 长汀县| 枣强县| 科尔| 新乡县| 河东区| 崇左市|