当前位置:网站首页>每日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");
}
}
边栏推荐
- Teach you how to build a permanent personal server!
- How to choose LAN instant messaging software
- 解析Activity启动-生命周期角度
- jvm 参数设置与分析
- CMOS level circuit analysis
- [a complete human-computer interface program framework]
- To understand again is the person in the song
- What is low code for digital Nova? What is no code
- Hardware development notes (VII): basic process of hardware development, making a USB to RS232 module (VI): creating 0603 package and associating principle graphic devices
- Record number of visits yesterday
猜你喜欢

buuctf misc 百里挑一

ENSP cloud configuration
![[tcapulusdb knowledge base] Introduction to tcapulusdb tcapsvrmgr tool (III)](/img/ce/b58e436e739a96b3ba6d2d33cf8675.png)
[tcapulusdb knowledge base] Introduction to tcapulusdb tcapsvrmgr tool (III)

Embedded development: embedded foundation callback function

Istio微服务治理网格流量管理核心资源控制器详解

Summary and Thinking on interface test automation

With the advent of the era of Internet of everything, Ruijie released a scenario based wireless zero roaming scheme

Journal quotidien des questions (6)
![[WUSTCTF2020]girlfriend](/img/a8/33fe5feb7bcbb73ba26a94d226cc4d.png)
[WUSTCTF2020]girlfriend

Deeply convinced plan X - system foundation summary
随机推荐
A statistical problem of shell script
After 2 years of outsourcing, I finally landed! Record my ByteDance 3 rounds of interviews, hope to help you!
Embedded development: embedded foundation callback function
awk 简明教程
[tcaplusdb knowledge base] Introduction to tcaplusdb tcapulogmgr tool (I)
POSIX AIO -- glibc 版本异步 IO 简介
Pytorch learning 3 (test training model)
Summary of redis master-slave replication principle
Axi bus
基于 xml 配置文件的入门级 SSM 框架整合
《预训练周刊》第51期:重构预训练、零样本自动微调、一键调用OPT
Learning records of numpy Library
Domestic database disorder
Details of istio micro service governance grid traffic management core resource controller
重读经典:《The Craft of Research(1)》
With the advent of the era of Internet of everything, Ruijie released a scenario based wireless zero roaming scheme
SFINAE
EventLoop learning
招标公告:上海市研发公共服务平台管理中心Oracle一体机软硬件维保项目
快速搭建一个自己的访问国外网站,搭建ss并开启bbr快速上网