当前位置:网站首页>每日3题(2):检查二进制字符串字段
每日3题(2):检查二进制字符串字段
2022-06-27 13:34:00 【程序猿不脱发2】
题目:
给你一个二进制字符串 s ,该字符串 不含前导零 。
如果 s 包含 零个或一个由连续的 ‘1’ 组成的字段 ,返回 true 。否则,返回 false 。
示例 1:
输入:s = “1001”
输出:false
解释:字符串中的 1 没有形成一个连续字段。
示例 2:
输入:s = “110”
输出:true
提示:
1 <= s.length <= 100
s[i] 为 ‘0’ 或 ‘1’
s[0] 为 ‘1’
思路:
这题的题意不太好理解,其实就是想检查字符串中有没有包含’01’, 建议这题看下就行, 不作为重要题目
java代码:
class Solution {
public boolean checkOnesSegment(String s) {
return !s.contains("01");
}
}
边栏推荐
- AGCO AI frontier promotion (6.27)
- 面试官:Redis的共享对象池了解吗?
- Learning records of numpy Library
- Why must Oracle cloud customers self test after the release of Oracle cloud quarterly update?
- [WUSTCTF2020]girlfriend
- [problem solving] which nodes are run in tensorflow?
- 基于JSP实现医院病历管理系统
- Read a poem
- 对半查找(折半查找)
- Record number of visits yesterday
猜你喜欢
The second part of the travel notes of C (Part II) structural thinking: Zen is stable; all four advocate structure
Summary and Thinking on interface test automation
Pre training weekly issue 51: reconstruction pre training, zero sample automatic fine tuning, one click call opt
Half find (half find)
Debug tool
基于SSM实现招聘网站
Pytorch learning 3 (test training model)
Yuweng information, a well-known information security manufacturer, joined the dragon lizard community to build an open source ecosystem
芯片供给过剩之际,进口最多的中国继续减少进口,美国芯片慌了
一次性彻底解决 Web 工程中文乱码问题
随机推荐
Domestic database disorder
以前国产手机高傲定价扬言消费者爱买不买,现在猛降两千求售
AcWing 第57 场周赛
EventLoop learning
ENSP cloud configuration
防火墙基础之华为华三防火墙web页面登录
Teach you how to build a permanent personal server!
Infiltration learning diary day20
Learning records of numpy Library
MySQL 索引及其分类
How ASP connects Excel
一次性彻底解决 Web 工程中文乱码问题
With the advent of the era of Internet of everything, Ruijie released a scenario based wireless zero roaming scheme
Cesium实现卫星在轨绕行
crane:字典项与关联数据处理的新思路
Type 'image' is not a subtype of type 'imageprovider < object > solution
Openfeign service interface call
SFINAE
赛迪顾问发布《“十四五” 关键应用领域之数据库市场研究报告》(附下载)
Shake hands with life and make peace