摘要: 方法一: 这个题目首先一看就有两个方法,一个是使用基于树的算法,也就是heap堆排序,经过一番奇巧淫技之后,时间复杂度是O(n*log k)。另一个就是使用数组的算法,可以选择的算法有选择排序O(n^2),快速排序O(nlogn),冒泡排序O(n^2)或者插入排序O(n^2)等等。那么本题目最快的方 阅读全文
posted @ 2021-04-20 16:59 Geeksongs 阅读(189) 评论(2) 推荐(0) 编辑
摘要: 这个题目有两种比较常用的方法,一种是暴力解法,时间复杂度是O(mn),一种是KMP算法,由于KMP算法一般都是ACM竞赛才会使用到,因此这里这里只提供Python的暴利解法。 题目如下: 使用Python暴利解答的代码如下: class Solution: def strStr(self, hays 阅读全文
posted @ 2021-04-20 16:10 Geeksongs 阅读(35) 评论(0) 推荐(0) 编辑

Coded by Geeksongs on Linux

All rights reserved, no one is allowed to pirate or use the document for other purposes.