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:
A
andB
will 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 ...
随机推荐
- Mysql如何将一张表重复数据删除
MySQL无法select 和 delete,update同时进行 只有将group By 出来不重复的数据进行insert到一张和之前同样类型的新表里面 转换思路,解决问题!
- TCP/IP 笔记 1.2 链 路 层
都是包含三种类型.根据类型字段的值来进行区分 2.4 SLIP:串行线路IPS L I P的全称是Serial Line IP.它是一种在串行线路上对 I P数据报进行封装的简单形式,在RFC 105 ...
- 开源项目weiciyuan运行前gradle调试过程记录
折腾了几个小时,终于能成功运行了,由于该项目使用的gradle版本过旧,需要做一些调整,具体如下 1.将使用gradle版本号改为你现在用的 2.将build tools版本号改为同上 3.将defa ...
- MyBatis配置Setting详细说明
该表格转载自http://blog.csdn.net/summer_yuxia/article/details/53169227 setting是指定MyBatis的一些全局配置属性,这是MyBati ...
- EZOJ #80
传送门 分析 经典的树型DP 我们记录dp[i][0/1]表示i的子树中到i的长度分别为偶数和奇数的长度和 dp2[i][0/1]则表示不在i的子树中的点到i的长度分别为偶数和奇数的长度和 然后根据边 ...
- 95E Lucky Country
传送门 题目大意 如果一个数中不包含除4和7之外的数字则是幸运数.有n个岛屿,通过双向道路连接.这些岛屿被分为几个地区.每个岛属于恰好一个区域,同一区域中的任何两个岛之间存在道路,不同区域的任何两个岛 ...
- redis过期时间设置
方法一: $redis->setex(,'huahua'); 方法二: $redis->set('name','huahua'); $redis->expire('name',3);
- Fiddler的Request Builder(Composer)模拟发送POST请求
传json格式: Parsed写: User-Agent: Fiddler Host: localhost:1455 Content-Type: application/json; charset=u ...
- javax.servlet.http.httpServletRequest接口
HttpServletRequest接口中常用的方法: - String getContentPath();//获取webapp根目录路径,如下图: 下面研究request到底是一个怎样的范围 ...
- c语言判断是否是utf8字符串,计算字符个数
#include <stdio.h> #include <string.h> #include <stdlib.h> /********************** ...