Digest中计算编辑距离以及前端性能测试工具的示例分析

发布时间:2021-09-18 09:41:44 作者:柒染
来源:亿速云 阅读:138

这期内容当中小编将会给大家带来有关Digest中计算编辑距离以及前端性能测试工具的示例分析,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

每天学点算法

谷歌面试题:计算编辑距离

两个字符串的编辑距离是指需要转化为另一个字符串所需要的最少插入、删除和置换的次数。比如 “kitten” 和 “sitting” 的编辑距离是3。

The edit distance between two strings refers to the minimum number of character insertions, deletions, and substitutions required to change one string to the other. For example, the edit distance between “kitten” and “sitting” is three: substitute the “k” for “s”, substitute the “e” for “i”, and append a “g”.

给定两个字符串,计算它们的编辑距离。

Given two strings, compute the edit distance between them.

def edit_distance(string1, string2):
    """Ref: https://bit.ly/2Pf4a6Z"""

    if len(string1) > len(string2):
        difference = len(string1) - len(string2)
        string1[:difference]

    elif len(string2) > len(string1):
        difference = len(string2) - len(string1)
        string2[:difference]

    else:
        difference = 0

    for i in range(len(string1)):
        if string1[i] != string2[i]:
            difference += 1

    return difference

print(edit_distance("kitten", "sitting")) #3
print(edit_distance("medium", "median")) #2

其他值得阅读

这将使你成为一个命令行忍者

原文:This Will Make You a Command-Line Ninja

Unix哲学

Write programs that do one thing and do it well. | 编写的程序只做一件事,而且要做得很好。 Write programs to work together. | 编写的程序要能协同工作。 Write programs to handle text streams, because that is a universal interface. | 编写处理文本流的程序,因为那是一个通用接口。

变量
如何监控Linux中的基本系统指标

原文:LFCA: How to Monitor Basic System Metrics in Linux

# get the system’s date and the time the system was turned on.
uptime -s
uptime -p

# To get a glimpse of the total and available memory and swap space on your system
free -h

# provides a summary of the real-time system metrics and displays the currently running processes that are managed by the Linux kernel.
top
# $ sudo apt install htop  [On Debian-based]
# $ sudo dnf install htop  [On RHEL-based]
htop

# The df command provides information on hard disk utilization per filesystem.
df -Th
免费的前端性能测试工具

FREE FRONT END PERFORMANCE TESTING TOOLS

To be mature you have to realize what you value most. 要想成为一个成熟的人,就必须认识到自己最宝贵的东西。

成功的前提是学会取舍

上述就是小编为大家分享的Digest中计算编辑距离以及前端性能测试工具的示例分析了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. html5前端性能测试的示例
  2. Python cookbook中字典相关计算问题的示例分析

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

yslow linux

上一篇:PHP常见的文件操作方式介绍

下一篇:用Python模拟网站中对JavaScript加密的方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》