Advertisement
alex0sunny

slide_subarray

Sep 12th, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. def get_len(a, b):
  2.     if len(a) > len(b):
  3.         a, b = b, a
  4.     res = 0
  5.     for i in range(-len(a) + 1, len(b)):
  6.         cur = 0
  7.         for j in range(len(a)):
  8.             if 0 <= i + j < len(b) and a[j] == b[i + j]:
  9.                 cur += 1
  10.                 res = max(res, cur)
  11.             else:
  12.                 cur = 0
  13.     return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement