自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(9)
  • 收藏
  • 关注

原创 [LeetCode P76] Minimum Window Substring

原题:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC".Note:

2017-08-29 10:46:20 222

原创 [LeetCode P72] 编辑距离Levenshtein Distance算法[经典动态规划]

突然就写到72题了…中间也遇到了一些难题,60~70的题目有好几题坑题,不过Unique Path里有一题挺不错的,我想用迷宫回溯的方法求解,发现时间越界,其实也是用DP,有空放上来。 原题:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (e

2017-08-25 10:54:29 402

原创 [LeetCode P45] Jump Game II

原题:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to r

2017-08-19 12:40:38 172

原创 [LeetCode P41] First Missing Positive

原题:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space.解

2017-08-14 13:05:34 167

原创 [LeetCode 37] Sudoku Solver回溯解法

原题:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.解决一个数独,我认为还是比较直观的,一直觉得计算

2017-08-12 14:24:04 472

原创 [LeetCode P32] Longest Valid Parentheses 四种解法

又是一道Hard题,但AC却很简单,用暴力算法,大概5-10分钟就搞定了,比较难的是这题有很多种解法,把这些解法都理解一遍比较好。四种解法都做了注释,可以直接看代码。/*原题:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) p

2017-08-11 01:44:22 603

原创 [Leetcode P28] Implement strStr()(KMP算法)

原题:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.刚看到这题,我就放了个string.find()上去:return haystack.find(needle);完美AC。 但是转念一想,这题虽然

2017-08-07 22:49:29 498

原创 [Leetcode P17] Letter Combinations of a Phone Number(看作递增加法器)

原题:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.(一个手机的九宫格)虽然这题不是很难,但是我

2017-08-05 01:08:20 229

原创 [Leetcode P15] Three Sum 三数之和

很有意思的问题,也让我重新看了一下第一题。 原题:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution s

2017-08-03 01:33:53 229

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除