随笔 - 395  文章 - 3  评论 - 49  阅读 - 85万

随笔分类 -  leetcode

Longest Palindromic Substring
摘要:http://www.felix021.com/blog/read.php?2040下面以字符串12212321为例,经过上一步,变成了 S[] = "$#1#2#2#1#2#3#2#1#";然后用一个数组 P[i] 来记录以字符S[i]为中心的最长回文子串向左/右扩张的长度(包括S[i]),比如S... 阅读全文
posted @ 2014-04-21 18:02 wf110 阅读(202) 评论(0) 推荐(0) 编辑
Permutation Sequence
摘要:Permutation SequenceTotal Accepted:6325Total Submissions:29550My SubmissionsThe set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and... 阅读全文
posted @ 2014-04-20 19:13 wf110 阅读(1527) 评论(0) 推荐(0) 编辑
Longest Substring Without Repeating Characters
摘要:charTables数组记录字符对应的位置。public class Solution { public int lengthOfLongestSubstring(String s) { if(null==s||0==s.length()) return 0; ... 阅读全文
posted @ 2014-04-18 10:43 wf110 阅读(231) 评论(0) 推荐(0) 编辑
Gray Code
摘要:[leetcode]Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. For example, given n = 2, return 阅读全文
posted @ 2014-04-10 10:36 wf110 阅读(311) 评论(0) 推荐(0) 编辑
Clone Graph
摘要:这里使用BFS来解本题,BFS需要使用queue来保存neighbors但这里有个问题,在clone一个节点时我们需要clone它的neighbors,而邻居节点有的已经存在,有的未存在,如何进行区分?这里我们使用Map来进行区分,Map的key值为原来的node,value为新clone的node,当发现一个node未在map中时说明这个node还未被clone,http://oj.leetcode.com/problems/clone-graph/ 1 public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) {... 阅读全文
posted @ 2014-03-21 18:45 wf110 阅读(322) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示