当前位置:网站首页>每日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");
}
}
边栏推荐
- Infiltration learning diary day20
- [dynamic programming] - Knapsack Problem
- [XMAN2018排位赛]通行证
- Awk concise tutorial
- 基于SSM实现招聘网站
- To understand again is the person in the song
- Completely solve the problem of Chinese garbled code in Web Engineering at one time
- Array related knowledge
- How to split microservices
- AXI总线
猜你喜欢

重读经典:《The Craft of Research(1)》

Openfeign service interface call
![[安洵杯 2019]Attack](/img/1a/3e82a54cfcb90ebafebeaa8ee1ec01.png)
[安洵杯 2019]Attack

基于JSP实现医院病历管理系统

Embedded development: embedded foundation callback function

Crane: a new way of dealing with dictionary items and associated data

Does Xinhua San still have to rely on ICT to realize its 100 billion enterprise dream?

crane:字典项与关联数据处理的新思路

Realization of hospital medical record management system based on JSP

类模板中可变参的逐步展开
随机推荐
scrapy
[XMAN2018排位赛]通行证
MySQL locking mechanism and four isolation levels
Cesium实现卫星在轨绕行
Firewall foundation Huawei H3C firewall web page login
为什么 Oracle 云客户必须在Oracle Cloud 季度更新发布后自行测试?
Intranet learning notes (8)
Awk concise tutorial
Yuweng information, a well-known information security manufacturer, joined the dragon lizard community to build an open source ecosystem
防火墙基础之华为华三防火墙web页面登录
一道shell脚本的统计题
Interviewer: do you understand redis' shared object pool?
AXI總線
What else can PLM do?
一次性彻底解决 Web 工程中文乱码问题
Clear self orientation
High efficiency exponentiation
Daily question brushing record (6)
How to choose LAN instant messaging software
爱可可AI前沿推介(6.27)