We are given two strings, A and B.

shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = 'abcde', then it will be 'bcdea' after one shift on A. Return True if and only if A can become B after some number of shifts on A.

Example 1:
Input: A = 'abcde', B = 'cdeab'
Output: true Example 2:
Input: A = 'abcde', B = 'abced'
Output: false

Note:

  • A and B will have length at most 100.

问 A的转化(平移)后能不能形成B

我们拼接A,然后查一下就行了

class Solution(object):
def rotateString(self, A, B):
"""
:type A: str
:type B: str
:rtype: bool
"""
Str=A+A
if B not in Str:
return False
else:
return True

75th LeetCode Weekly Contest Rotate String的更多相关文章

  1. 75th LeetCode Weekly Contest Smallest Rotation with Highest Score

    Given an array A, we may rotate it by a non-negative integer K so that the array becomes A[K], A[K+1 ...

  2. 75th LeetCode Weekly Contest Champagne Tower

    We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so ...

  3. 75th LeetCode Weekly Contest All Paths From Source to Target

    Given a directed, acyclic graph of N nodes.  Find all possible paths from node 0 to node N-1, and re ...

  4. LeetCode Weekly Contest 8

    LeetCode Weekly Contest 8 415. Add Strings User Accepted: 765 User Tried: 822 Total Accepted: 789 To ...

  5. leetcode weekly contest 43

    leetcode weekly contest 43 leetcode649. Dota2 Senate leetcode649.Dota2 Senate 思路: 模拟规则round by round ...

  6. LeetCode Weekly Contest 23

    LeetCode Weekly Contest 23 1. Reverse String II Given a string and an integer k, you need to reverse ...

  7. Leetcode Weekly Contest 86

    Weekly Contest 86 A:840. 矩阵中的幻方 3 x 3 的幻方是一个填充有从 1 到 9 的不同数字的 3 x 3 矩阵,其中每行,每列以及两条对角线上的各数之和都相等. 给定一个 ...

  8. LeetCode Weekly Contest

    链接:https://leetcode.com/contest/leetcode-weekly-contest-33/ A.Longest Harmonious Subsequence 思路:hash ...

  9. LeetCode算法题-Rotate String(Java实现)

    这是悦乐书的第317次更新,第338篇原创 在开始今天的算法题前,说几句,今天是世界读书日,推荐两本书给大家,<终身成长>和<禅与摩托车维修艺术>,值得好好阅读和反复阅读. 0 ...

随机推荐

  1. saltstact的安装与配置

    Saltstack是一个服务器基础架构集中化管理平台,具备配置管理.远程执行.监控等功能,人们一般习惯把saltstack比作成简化版的puppet和加强版的func.saltstack基于Pytho ...

  2. 杭电acm 1021题

    题意是要求能被3整除的数所以为了避免大数据的产生,直接对每个数据求余,然后相加 #include "iostream" using namespace std; int main( ...

  3. g2o20160430下的csparse文件夹内的CMakeLists.txt

    1. g2o20160430下的csparse文件夹内的CMakeLists.txt cmake_minimum_required(VERSION 2.6) PROJECT(csparse) SET( ...

  4. Luogu 3586 [POI2015]LOG

    考虑离散化后开权值线段树. 设序列中不小于$s$的数有$cnt$个,小于$s$的数的和为$sum$. 那么操作Z能成功的充要条件是$sum \geq (c - cnt) * s$. 如果序列中不小于$ ...

  5. Entity Framework Tutorial Basics(35):Local Data

    Local Data The Local property of DBSet provides simple access to the entities that are currently bei ...

  6. [坑]Linux MySQL环境表名默认区分大小写

    不区分大小写设置 1.用ROOT登录,修改/etc/my.cnf 2.在[mysqld]下加入一行:lower_case_table_names=1 3.重新启动数据库即可 systemctl res ...

  7. GUID介绍

    GUID介绍 GUID(Global unique identifier)全局唯一标识符,它是由网卡上的标识数字(每个网卡都有唯一的标识号)以及 CPU 时钟的唯一数字生成的的一个 16 字节的二进制 ...

  8. oracle connect by 递归,反递归,自动补全查询实现

    递归: select *    from t_pams_solution t   start with t.id is null  connect by prior id = t.parent_id  ...

  9. 分层最短路-2018南京网赛L

    大概题意: 题意:N个点,M条带权有向边,求将K条边权值变为0的情况下,从点1到点N的最短路. 拓展:可以改变K条边的权值为x 做法:把每个点拆成k个点,分别表示还能使用多少次机会,构造新图. 实际写 ...

  10. 读《JavaScript权威指南》笔记(三)--对象

    1.对象介绍 对象是JavaScript的基本数据类型.对象是一种复合值:它将很多值(原始值或者其他对象)聚合在一起,可通过名字访问这些值.对象也可看做是属性的无序集合,每个属性都是一个名/值对.属性 ...