算法
bingo_boy
这个作者很懒,什么都没留下…
展开
-
Leetcode —— Two Sum
Leetcode —— Two Sum Problem description link Two SumAnalyse:原创 2015-04-30 00:08:58 · 539 阅读 · 1 评论 -
Longest Palindromic Substring--leetcode
我的解法v1:思路:查找字符串中aa或者aba类似的字符字串,然后开始往两边拓展代码:class Solution: # @param {string} s # @return {string} def longestPalindrome(self, s): ret = '' if len(s) == 1: ret原创 2015-06-23 14:28:37 · 391 阅读 · 0 评论 -
4th Median of Two Sorted Arrays -- leetcode
我的解法思路:比较列表nums1中间和nums2中间的数,如果第一个列表小于第二个列表,那么不可能包含中间数的一串子序列总共有两串,nums1中间数前面的一串和nums2中间数后面的一串,比较长短,删除比较短的那一串(每次删掉其中一串序列的一半),不断递归,直到其中的一个列表长度缩短为2,然后插入排序(log级别),最后输出结果。代码如下:class Solution: # @para原创 2015-06-22 13:35:43 · 390 阅读 · 0 评论 -
String to Integer (atoi) -- leetcode
天了噜,条件真多大体题意: string to integer。。。原创 2015-06-23 12:58:26 · 341 阅读 · 0 评论 -
Longest Common Prefix --leetcode
思路一思路:先查找最短的字符串,赋值给ret,然后从第一个字符串开始两两比较,比较ret与字符串数组里的公共字串。返回最后结果。代码:class Solution: # @param {string[]} strs # @return {string} def longestCommonPrefix(self, strs): if len(strs) =原创 2015-06-25 15:59:26 · 413 阅读 · 0 评论 -
Regular Expression Matching--leetcode
解法一思路: 写的第一个版本,知道是动态规划,但是不够简洁,因为动态方程 根本就没有写明白!!!!有点暴力的意思,其中还用到了剪枝操作代码:class Solution: # @param {string} s # @param {string} p # @return {boolean} def __init__(self): self.is原创 2015-06-24 09:41:20 · 450 阅读 · 0 评论 -
算法 学习
1、并查集 & 字典树 & 欧拉路径 * 并查集:路径压缩 * 字典树:用来把unique string转化为int * 欧拉路径(顺带哈密顿路径)判断 poj2513解题报告原创 2015-09-16 21:24:07 · 443 阅读 · 0 评论 -
最大子序列和
问题 Given a sequence a[1],a[2],a[3]……a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14. 问题传送门 密码:me原创 2016-03-17 23:27:27 · 436 阅读 · 0 评论