718
来源:互联网 发布:考驾证下载什么软件 编辑:程序博客网 时间:2024/06/06 03:07
2017.10.24
重复字符串A,当A的长度大于B的长度的2倍的时候,停止。
在此期间,一直检查B是不是A的子串,如果是,就提前停止。返回重复次数。
这个时候,如果B仍旧不是A的子串,那么就返回-1;
public class Solution { /* * @param : string A to be repeated * @param : string B * @return: the minimum number of times A has to be repeated */ public int repeatedString(String A, String B) { // write your code hereif(A.contains(B)){return 1;}if(A.length() == 0){return -1;}String tmp = A;int count = 1;while(tmp.length() <= 2* B.length()){if(tmp.contains(B)){return count;}tmp = tmp + A;count ++;}if(tmp.contains(B)){return count;}else{return -1;} }}
阅读全文
0 0
- 718
- 718惨案
- Leetcode 718
- 上传资源718个
- codeforces 718C
- Codeforces 718C
- CodeForces 718A
- TopCoder SRM 718
- Topcoder SRM 718 Hard
- Leetcode-个人题解718
- Thinstall v2.718 by Jitit
- 数学专项number_theory:UVa 718
- UVA 718 - Skyscraper Floors(数论)
- 718AEfim and Strange Grade
- □ 影片名:《冰暴》(718)
- Programmer's Notepad 2.0.8 (build 718)
- uva 718 - Skyscraper Floors(模拟优化)
- uva 718 - Skyscraper Floors(数论+bfs)
- KMP算法之java实现
- [Tomcat]idea安装使用最新版Tomcat
- Weex入门教程
- ndk-build编译64位.so,出现ndk error: cast from 'int*' to 'int' loses precision [-fpermissive]
- iOS(OC)—仿支付宝我的二维码页面系统亮度调整
- 718
- Python(4)操作列表
- Spring Boot构建RESTful API与单元测试
- django uWSGI Nginx
- operation category read is not supported in state standby
- java发起https请求时证书相关问题
- Linux 安装中文输入法报 cannot find a valid baseurl for repo base
- (python)可变对象/不可变对象
- Vmware Workstation 不可恢复错误:(vcpu-0)