llbai  
          
              
                2022 年7 月 26 日 22:10
               
              1 
           
         
        
          
s 的旋转操作 就是将 s 最左边的字符移动到最右边。
例如, 若 s = ‘abcde’,在旋转一次之后结果就是’bcdea’。 
 
示例 1:
输入: s = "abcde", goal = "cdeab"
输出: true
示例 2:
输入: s = "abcde", goal = "abced"
输出: false
 
1 <= s.length, goal.length <= 100 
s 和 goal 由小写英文字母组成 
 
 
编写一个函数, 执行上述操作
class Solution:
    def rotateString(self, s: str, goal: str) -> bool:
    # your code here
题目难度:简单796. 旋转字符串 - 力扣(LeetCode) 
         
        
           
         
            
       
      
        
          
          
            joyoko  
          
              
                2022 年7 月 27 日 05:51
               
              3 
           
         
        
          class Solution:
    def rotateString(self, s: str, goal: str) -> bool:
        # your code here
        n = len(s)
        while n > 0:
            round_result = s[1:] + s[0]
            if round_result == goal:
                return True
            s = round_result
            n -= 1
        return False
 
        
           
         
            
       
      
        
        
          class Solution:
    def rotateString(self, s: str, goal: str) -> bool:
        l_s = list(s)
        last = l_s[-1]
        l_g = list(goal)
        while l_s[0] != last:
            a = l_s.pop(0)
            l_s.append(a)
            if l_s == l_g:
                return True
        return False
 
        
           
         
            
       
      
        
        
              def rotateString(s: str, goal: str) -> bool:
        if s == goal:
            return True
        for i in range(len(s)-1):
            s=s[1:]+s[0]
            if s == goal :
                return True
        return False
 
        
           
         
            
       
      
        
          
          
            qunzi  
          
              
                2023 年3 月 6 日 07:42
               
              9 
           
         
        
          def rotateString( s: str, goal: str) -> bool:
    i=0
    tmp_s=list(s)
    tmp_g=list(goal)
    while i<=len(tmp_s):
        a=tmp_s[0]
        tmp_s.remove(a)  ##移除找到第一个元素,后面的不管
        tmp_s.append(a)
        i+=1
        return True if tmp_s==tmp_g else False
rotateString(s = "abcda", goal = "eaabcde") 
        
           
         
            
       
      
        
          
          
            lekaixin  
          
              
                2023 年12 月 4 日 04:05
               
              10 
           
         
        
          def rotateString(s: str, goal: str) -> bool:
    n=1
    while n<len(s):
        s=s[1:]+s[0]
        if s==goal:
            return True
        n+=1
    return False
assert rotateString("abcde","cdeab")==True
assert rotateString("abcde","abced")==False