【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 给定一个小写字母串,回答分别把每个位置上的字符替换为'#'后的本质不同的子串数. 题解 首先横 ...
随机推荐
- Jenkins 参数化构建(Git Parameter)
由于我们在测试过程中,可能需要在多个测试环境跑用例,这个时候就需要jenkins参数化了. Jenkins参数化一般常用的有两种方式:Choice和String Parameter两种 (1)Choi ...
- Selenium常用API的使用java语言之10-获取断言信息
不管是在做功能测试还是自动化测试,最后一步需要拿实际结果与预期进行比较.这个比较的称之为断言. 我们通常可以通过获取title .URL和text等信息进行断言.text方法在前面已经讲过,它用于获取 ...
- Selenium常用API的使用java语言之5-selenium元素定位
1.selenium定位方法 Selenium提供了8种定位方式. id name class name tag name link text partial link text xpath css ...
- 面试官:讲讲mysql表设计要注意啥
内容时参考一个博主的,内容写的很好,就忍不住拿过来了,如遇到,请见谅 参考连接:https://www.cnblogs.com/rjzheng/p/11174714.html
- learning scala PartialFunction
Partial函数的定义 scala> val isVeryTasty: PartialFunction[String, String] = { case "Glazed Donut& ...
- DOM操作1
1.DOM文档对象模型:操作页面元素(标签) html文件看成一个文档,把文档看成一个对象 xml也是一种文档,标签自定义,系统不自带标签,偏向于存储数据 2.DOM树:由文档及文档中的所以元素(标签 ...
- K Simple question (第十届山东理工大学ACM网络编程擂台赛 正式赛)
题解:素数筛+唯一分解定理 可以把素数筛那部分放到while之外,减小时间复杂度. #include <stdio.h> #include <stdlib.h> #includ ...
- Mysql远程无法连接
#登陆mysql $ mysql -uroot -p mysql> use mysql; mysql> update user set host = '%' where user = 'r ...
- (转)kvm初识
一 虚拟化介绍 1 常见虚拟化软件VMware系列VMware workstation.VMware vsphere(VMware esxi).VMware Fusion(Mac) Xen 开源 半虚 ...
- ICEM-带死角弯管
原视频下载地址:https://yunpan.cn/cqRiHaQiLi8I7 访问密码 b5c6