75th LeetCode Weekly Contest Rotate String
We are given two strings, A and B.
A 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:
AandBwill have length at most100.
问 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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- LeetCode Weekly Contest 8
LeetCode Weekly Contest 8 415. Add Strings User Accepted: 765 User Tried: 822 Total Accepted: 789 To ...
- leetcode weekly contest 43
leetcode weekly contest 43 leetcode649. Dota2 Senate leetcode649.Dota2 Senate 思路: 模拟规则round by round ...
- LeetCode Weekly Contest 23
LeetCode Weekly Contest 23 1. Reverse String II Given a string and an integer k, you need to reverse ...
- Leetcode Weekly Contest 86
Weekly Contest 86 A:840. 矩阵中的幻方 3 x 3 的幻方是一个填充有从 1 到 9 的不同数字的 3 x 3 矩阵,其中每行,每列以及两条对角线上的各数之和都相等. 给定一个 ...
- LeetCode Weekly Contest
链接:https://leetcode.com/contest/leetcode-weekly-contest-33/ A.Longest Harmonious Subsequence 思路:hash ...
- LeetCode算法题-Rotate String(Java实现)
这是悦乐书的第317次更新,第338篇原创 在开始今天的算法题前,说几句,今天是世界读书日,推荐两本书给大家,<终身成长>和<禅与摩托车维修艺术>,值得好好阅读和反复阅读. 0 ...
随机推荐
- Solr根据参考点的坐标来返回范围内的小区和距离
@Test public void query() throws Exception{ SystemDefaultHttpClient httpClient = new SystemDefaultHt ...
- 【273】利用ArcPy建立处理数据的脚本
这个脚本可以直接运行处理程序,首先在 ArcPy 上面测试,成功后写入文件,下面的代码实现将指定文件夹内部的栅格数据进行 Calculate Statistics 操作,否则在进行专题图制作的时候会出 ...
- Arduino Uno 在win7 64位下的驱动问题
1.解压[mdmcpq.inf_amd64_neutral_fbc4a14a6a13d0c8.rar],将[mdmcpq.inf_amd64_neutral_fbc4a14a6a13d0c8]文件夹复 ...
- java中怎么把String转化为字符数组呢?
我想让用户输入一组字符串,然后将这个字符串的每一个赋给一个char.即,abcde char ch[]=new char[5]; ch[0]=a;ch[1]=b;..... 解决方案如下图所示: St ...
- R: 聚类分析
判别与聚类的比较: 聚类分析和判别分析有相似的作用,都是起到分类的作用. 判别分析是已知分类然后总结出判别规则,是一种有指导的学习: 聚类分析则是有了一批样本,不知道它们的分类,甚至连分成几类也不知道 ...
- Django框架 之 ORM查询操作详解
Django框架 之 ORM查询操作详解 浏览目录 一般操作 ForeignKey操作 ManyToManyField 聚合查询 分组查询 F查询和Q查询 事务 Django终端打印SQL语句 在Py ...
- 36-OLED显示实验
1.OLED原理 有四种工作模式 先把片选拉低,如果是写的话,把RD拉高,在WR的上升沿写数据到数据线上,DC决定是数据还是命令.读类似了. 2.程序显示原理 3.代码 4.自己写代码 http:// ...
- Bootstrap 的 Modal
一.简介 Modal 就是弹出框,这里 有一个例子. Modal 的完整代码如下: <div class="modal fade" tabindex="-1&quo ...
- 使用swiper.animate时,给一个对象添加两个动画且动画循环的方法
swiper官网上给对象加一个动画的方法是 <div class="swiper-slide"> <p class="ani" swiper- ...
- 开启VS的JavaScript调试
前提条件,设置我们的IE 去掉勾,即启用调试然后再JS代码片段中输入debugger.注意:如果IE开启了F12调试面板, VS是不会捕获JS代码片段中的debugger断点.