【Leetcode_easy】796. Rotate String
problem
solution1:
class Solution {
public:
bool rotateString(string A, string B) {
if(A.size()!=B.size()) return false;
if(A.size()== && B.size()==) return true;//errr...
for(int i=; i<A.size(); ++i)
{
if(A.substr(i, A.size()-i)+A.substr(, i) == B) return true;
}
return false;
}
};
solution2:
class Solution {
public:
bool rotateString(string A, string B) {
return (A.size()==B.size() && ((A+A).find(B)!=string::npos));
}
};
参考
1. Leetcode_easy_796. Rotate String;
2. Grandyang;
完
【Leetcode_easy】796. Rotate String的更多相关文章
- 【LeetCode】796. Rotate String 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...
- 【Leetcode_easy】942. DI String Match
problem 942. DI String Match 参考 1. Leetcode_easy_942. DI String Match; 完
- 【Leetcode_easy】844. Backspace String Compare
problem 844. Backspace String Compare solution1: class Solution { public: bool backspaceCompare(stri ...
- 【Leetcode_easy】686. Repeated String Match
problem 686. Repeated String Match solution1: 使用string类的find函数: class Solution { public: int repeate ...
- 【Leetcode_easy】606. Construct String from Binary Tree
problem 606. Construct String from Binary Tree 参考 1. Leetcode_easy_606. Construct String from Binary ...
- 【leetcode_easy】541. Reverse String II
problem 541. Reverse String II 题意: 给定一个字符串,每隔k个字符翻转这k个字符,剩余的小于k个则全部翻转,否则还是只翻转剩余的前k个字符. solution1: cl ...
- 【CF1132F】Clear the String(动态规划)
[CF1132F]Clear the String(动态规划) 题面 CF 题解 考虑区间\(dp\). 增量考虑,每次考虑最后一个字符和谁一起删去,然后直接转移就行了. #include<io ...
- leetcode 344. Reverse String 、541. Reverse String II 、796. Rotate String
344. Reverse String 最基础的旋转字符串 class Solution { public: void reverseString(vector<char>& s) ...
- 【Hihocoder1413】Rikka with String(后缀自动机)
[Hihocoder1413]Rikka with String(后缀自动机) 题面 Hihocoder 给定一个小写字母串,回答分别把每个位置上的字符替换为'#'后的本质不同的子串数. 题解 首先横 ...
随机推荐
- html学习 菜鸟
1HTML 不是一种编程语言,而是一种标记语言 2只有 <body>区域才会在浏览器中显示. 3<!DOCTYPE>声明有助于浏览器中正确显示网页.doctype 声明是不区分 ...
- ask confirm shell
#/bin/bash BASEDIR=$(cd $() && pwd) cd $BASEDIR>/dev/null usage="Usage: $0 -o/--org ...
- 前端面试:Vue.js常见的问题
摘自今日头条用户:代码开发 原文链接: https://www.toutiao.com/a6683120112255369732/?tt_from=mobile_qq&utm_campaign ...
- 使用UEditor 报错Cannot read property 'nodeType' of undefined 解决办法
报如下错误 解决办法: //对编辑器的操作最好在编辑器ready之后再做 ue.ready(function() { }) <!-- 实例化编辑器 --> <script type= ...
- svn优点跟缺点?
优点: 1.svn优点:集中式管理,管理方式在服务端配置好,客户端只需要同步提交即可,使用方便,操作简单,很容易就可以上手 2.在服务端统一控制好访问权限,利用代码的安全管理. 3.所有的代码以服务端 ...
- kubernetes跨网段pod网络不通问题
kubernetes跨网段问题 k8s的master是10.10.10.0网段,新加了一些node,网段是172.16.100.0网段,造成容器直接网络不能相互访问. 部署k8s的时候也部署了flan ...
- 为什么final类型map和list内容可以修改
URL地址:https://blog.csdn.net/AlbertFly/article/details/76855367
- PHP全栈学习笔记26
php 验证码 <?php /* *@Author: 达叔小生 **/ header("Content-type:image/png"); // 发送头部信息,生成png图片 ...
- zabbix (6) 为主机添加监控项,触发器,动作
先了解一下zabbix的相关概念 监控项(iterms):一个具体的指标,比如某个人的体重. 键(key):通过定义(自定义或者zabbix自带)的key获取相应指标的具体值,比如这个人的体重50斤 ...
- Asis_2016_b00ks wp
目录 程序基本信息 程序漏洞 利用思路 exp脚本 参考 程序基本信息 程序漏洞 有一个读入函数,程序的所有输入都靠它读取,这个程序有个很明显的off_by_one漏洞,在输入时多输入一个0字符. 利 ...