翻转子串
来源:互联网 发布:淘宝网副总裁张勤 编辑:程序博客网 时间:2024/05/16 14:36
题目描述
给定两个字符串s1,s2,请返回bool值代表s2是否由s1旋转而成。字符串中字符为英文字母和空格,区分大小写
解析:通过旋转一个字串即可
public boolean checkReverseEqual(String s1, String s2) {//安全性检查if(s1==null||s2==null)return false;String tempStr1 = s1;for (int i = 0; i < s1.length(); i++) {String tempStr2;tempStr2 = tempStr1.substring(1, s1.length())+ tempStr1.substring(0, 1);if (tempStr2.equals(s2))return true; //保存 tempStr1 = tempStr2;}return false;}
0 0
- 翻转子串
- 翻转子串
- 翻转子串(Java)
- 翻转子串
- 翻转子串
- 牛客网 | 翻转子串
- 翻转子串
- 翻转子串
- 字符串子串翻转
- 翻转子串
- 翻转子串
- 翻转子串
- nowcoder->翻转子串
- 翻转子串
- 翻转子串
- 翻转子串
- 第四天 翻转子串
- 翻转字符串中的子串
- PDM与Excel利用VB脚本进行互导
- ubuntu下搭建rust到intellij开发环境
- XML基本知识
- API注册表函数
- hdu 5299 Circles Game(博弈)
- 翻转子串
- oc构造方法
- 创建Struts2项目
- KMP算法
- html学习笔记
- ShellExecute使用详解
- epoll的两种触发模式
- iOS开发轻松搞定C语言面试—— 算法
- hdu 5314 Happy King 树点分冶 树状数组