当前位置:网站首页>Interview question 01.09. string rotation
Interview question 01.09. string rotation
2022-07-28 01:41:00 【Welcome to the confrontation Road】
Subject requirements :
String rotation . Given two strings s1 and s2, Please write code to check s2 Is it s1 It's spinning ( such as ,waterbottle yes erbottlewat Rotated string ).
Topic understanding :
The essence of rotation is to split a string into two substrings and then recombine them to see whether it satisfies the other string , Equivalent to double string .
Example 1:
Input :s1 = "waterbottle", s2 = "erbottlewat"
Output :True
Example 2:
Input :s1 = "aa", s2 = "aba"
Output :False
class Solution {
public:
bool isFlipedString(string s1, string s2) {
if(s1.size() != s2.size())
return false;
string s = s2 + s2;
int a = s.find(s1);
if(a!=-1)
return true;
else
return false;
}
};
Experience :
string s1="zzabc";
s1.find("abc")
If found, return the subscript , Return if not found -1
边栏推荐
- Byte monthly salary 28K, share a wave of my automation testing experience
- Codeforces summer training weekly (7.14~7.20)
- Flutter--密码登录注册界面
- 如何让数字零售承接起流量时代和留量时代的发展重任,或许才是关键所在
- Flutter 通话界面UI
- Opengauss active / standby architecture works with keeplive
- 负载均衡SLB
- Qt 绘制系统简介
- 华为“天才少年”稚晖君又出新作,从零开始造“客制化”智能键盘
- I want to get 20K after 3 years of experience, but I haven't got it for half a month?
猜你喜欢

了解Shader

Icml2022 | online decision transformer

Baidu PaddlePaddle easydl: when AI enters the factory, "small bearing" can also turn "big industry"

“蔚来杯“2022牛客暑期多校训练营3 补题题解(A、C、J)

Qlib tutorial - based on source code (II) local data saving and loading

Sort out SQL performance optimization and collect classics!

26.抽象化和模板思想

Anfulai embedded weekly report no. 275: 2022.07.18--2022.07.24

现货白银如何计算盈亏

Qlib教程——基于源码(二)本地数据保存与加载
随机推荐
Three instance
String
[game] Nintendo Nintendo switch ultra detailed purchase / use guide and precautions (continuous update according to your own use...)
Leetcode 2341. How many pairs can an array form
ICML2022 | 在线决策Transformer
Cesium add annular diffusion ripple
C语言·指针
Interpretation of new features | the restriction of MySQL 8.0 on gtid is lifted
Dart code comments and documentation specification
Realize OCR language recognition demo (II) - display and interaction of pictures and recognition content
Flutter--密码登录注册界面
How to make digital retail undertake the development task of the era of traffic and retention may be the key
Software test interview question: what are the performance test indicators?
面试题 01.08. 零矩阵
Data problems can also be found if there is a space at the end of the field value of MySQL query criteria
2022/07/27 learning notes (Day17) code blocks and internal classes
梳理 SQL 性能优化,收藏经典!
Baidu PaddlePaddle easydl: when AI enters the factory, "small bearing" can also turn "big industry"
Cross domain requests in nodejs
Cesium add inundation analysis measurement area