mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-12 15:44:12 +08:00
Replace bandit, flake8, isort, and pyupgrade with ruff (#8178)
* Replace bandit, flake8, isort, and pyupgrade with ruff * Comment on ruff rules * updating DIRECTORY.md --------- Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -6,13 +6,13 @@ to find edit distance.
|
||||
The aim is to demonstate up bottom approach for solving the task.
|
||||
The implementation was tested on the
|
||||
leetcode: https://leetcode.com/problems/edit-distance/
|
||||
"""
|
||||
|
||||
"""
|
||||
Levinstein distance
|
||||
Dynamic Programming: up -> down.
|
||||
"""
|
||||
|
||||
import functools
|
||||
|
||||
|
||||
def min_distance_up_bottom(word1: str, word2: str) -> int:
|
||||
"""
|
||||
@ -25,13 +25,10 @@ def min_distance_up_bottom(word1: str, word2: str) -> int:
|
||||
>>> min_distance_up_bottom("zooicoarchaeologist", "zoologist")
|
||||
10
|
||||
"""
|
||||
|
||||
from functools import lru_cache
|
||||
|
||||
len_word1 = len(word1)
|
||||
len_word2 = len(word2)
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def min_distance(index1: int, index2: int) -> int:
|
||||
# if first word index is overflow - delete all from the second word
|
||||
if index1 >= len_word1:
|
||||
|
Reference in New Issue
Block a user