0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AtCoder B - String Rotation

Last updated at Posted at 2022-05-08

問題

回答

s = input() 
t = input()
size = len(s)

flag = False

for i in range(100):
  str = s[:size - i] # 元の配列から末尾を削除する
  n = s[-i:]
  final_str = n + str # 元の配列の先頭に持っていく
  if final_str == t:
    flag = True

if flag == True:
  print('Yes')
else:
  print('No')

ポイント

フラグ問題。

タプルを使用する。

  str = s[:size - i] # 元の配列から末尾を削除する。
  n = s[-i:] # 元の配列から末尾を取得しnに格納。
  final_str = n + str # 元の配列の先頭に持っていく。

一度、for i in range(size):にして通らなかったが、範囲を100に変更してAC。

久しぶりの自力AC。泣いた。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?