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 3 years have passed since last update.

配列内に特定の部分配列が存在するか判定する

Posted at

Code

target = [1, 2, 3, 4, 5, 6, 7, 8, 9]
pattern = [2, 3]

found = False
for i in range(len(target) - len(pattern) + 1):
    if pattern == target[i:i+len(pattern)]:
        found = True
        break

print(found)
0
0
1

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?