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

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

LeetCode 1016. Binary String With Substrings Representing 1 To N

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

Given a binary string?s?and a positive integer?n, return?true?if the binary representation of all the integers in the range?[1, n]?are?substrings?of?s, or?false?otherwise.

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

?

Example 1:

Input: s = "0110", n = 3

Output: true

Example 2:

Input: s = "0110", n = 4

Output: false

?

Constraints:

  • 1 <= s.length <= 1000

  • s[i]?is either?'0'?or?'1'.

  • 1 <= n <= 109

使用自帶函數(shù)Integer.toBinaryString()就可以的,遍歷確認(rèn)接,下面是代碼:

Runtime:?0 ms, faster than?100.00%?of?Java?online submissions for?Binary String With Substrings Representing 1 To N.

Memory Usage:?40.4 MB, less than?72.27%?of?Java?online submissions for?Binary String With Substrings Representing 1 To N.


LeetCode 1016. Binary String With Substrings Representing 1 To N的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
尉氏县| 宿州市| 甘孜县| 霍邱县| 清徐县| 紫云| 古浪县| 福鼎市| 当涂县| 翁牛特旗| 和硕县| 雷波县| 湖口县| 乐亭县| 周至县| 罗山县| 禹城市| 诸城市| 湾仔区| 荔浦县| 沁阳市| 公主岭市| 新兴县| 平南县| 宜都市| 漳平市| 永登县| 霍山县| 卢氏县| 福安市| 兴国县| 贵阳市| 行唐县| 庆元县| 泸定县| 汽车| 灌南县| 衡东县| 长岭县| 高青县| 卫辉市|