旋转字符串解题 您所在的位置:网站首页 旋转函数的解题思路 旋转字符串解题

旋转字符串解题

2024-07-11 09:48| 来源: 网络整理| 查看: 265

题目描述 字符串旋转: 给定两字符串A和B,如果能将A从中间某个位置分割为左右两部分字符串(都不为空串),并将左边的字符串移 动到右边字符串后面组成新的字符串可以变为字符串B时返回true。 例如:如果A=‘youzan’,B=‘zanyou’,A按‘you’‘zan’切割换位后得到‘zanyou’和B相同返回true。 示例1 输入 "youzan","zanyou" 返回值 true 示例2 输入 "youzan","zyouan" 返回值 false 代码实现 import java.util.*; public class Solution { /** * 旋转字符串 * @param A string字符串 * @param B string字符串 * @return bool布尔型 */ public boolean solve (String A, String B) { // write code here if(A.length() != B.length()){ return false; } int dex = 0; for(int i =0;i


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有