- 博客(9)
- 资源 (11)
- 收藏
- 关注
原创 寻找一个字符串的重复子串 后缀数组
什么是后缀数组 令字符串 S=S[1]S[2]...S[n]S=S[1]S[2]...S[n]{\displaystyle S=S[1]S[2]...S[n]} , S[i,j]S[i,j]{\displaystyle S[i,j]} 表示SS {\displaystyle S} 的子字符串,下标从ii {\displaystyle i} 到 jj{\displaystyle j} 。 SS{...
2018-06-21 22:53:18 5890
原创 192. Word Frequency 使用shell统计词频
答案 cat words.txt | sed 's/ /\n/g' | sed '/^$/d' | sort | uniq -c | awk '{print $2, $1}' | sort -nrk2 解释 使用sed将空格替换成换行,并且删除空白行 然后使用sort进行排序然后统计出词频 最后将结果以答案要求的方式输出...
2018-06-18 16:51:00 6148
原创 剑指offer 矩阵中的路径 回溯
# coding:utf-8 # !/usr/bin/env python # Time: 2018/6/11 9:09 # Author: sty # File: Findpath.py next_state = [[0, -1], [0, 1], [1, 0], [-1, 0]] class MatrixPath(): def has_path(self, array, r...
2018-06-11 10:16:43 5629
原创 python 通过双栈实现队列
开始做法 # coding:utf-8 # !/usr/bin/env python # Time: 2018/6/6 9:32 # Author: sty # File: stack_queue.py class Solution(): def __init__(self): self.stack1 = [] self.stack2 = []...
2018-06-06 09:51:14 5638
原创 通过前序遍历和中序遍历构建二叉树 python实现
前言 通过前序遍历和中序遍历构建二叉树的原理,主要是找前序遍历根节点在中序遍历中的位置,然后将二叉树而成左子树和右子树,然后依次进行这样的操作,思路还是比较简单的 代码 class Node: def __init__(self, data, left, right): self.data = data self.left = left ...
2018-06-06 09:12:19 11415 5
原创 python 浮点数未解之谜
疑问: print(8.1+0.03) ouput: 8.129999999999999 print(0.1+0.1+0.1-0.3) output: 5.551115123125783e-17 结论 多次遇到这个问题,第二遍看,依然没有理清楚怎么回事!!!下次继续看!!! 参考文档: 浮点数的二进制表示学习笔记 浮点数算法:争议和限制 浮点数的二进制表示 二、...
2018-06-05 15:57:04 5330
原创 LeetCode 10. Regular Expression Matching python特性、动态规划、递归
前言 本文主要提供三种不同的解法,分别是利用python的特性、动态规划、递归方法解决这个问题 使用python正则属性 import re class Solution2: # @return a boolean def isMatch(self, s, p): return re.match('^' + p + '$', s) != None ...
2018-06-05 09:14:21 6830
item_seleted
2019-01-22
python画小猪佩奇
2019-01-20
Box2D_v2.1.2已经编译好的文件
2018-11-07
Box2D_v2.1.2
2018-11-07
2018 Google kickstart Problem A. Planet Distance 输入数据
2018-05-27
笨方法学python3 Learn Python 3 the Hard Way
2018-04-06
用python进行数据分析 第二版 Python for Data Analysis, 2nd Edition
2018-04-06
SQL与关系数据库理论:如何编写健壮的SQL代码 第二版
2018-02-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人