随笔分类 -  Leetcode

摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Pan 阅读全文
posted @ 2016-06-29 17:08 ranran1203 阅读(239) 评论(0) 推荐(0)
摘要:Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: For example, Give 阅读全文
posted @ 2016-06-29 16:18 ranran1203 阅读(166) 评论(0) 推荐(0)
摘要:Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) fromstart to end, such that: For example, Given:start  阅读全文
posted @ 2016-06-29 15:13 ranran1203 阅读(254) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given[100, 4, 200, 1, 3, 2],The longest 阅读全文
posted @ 2016-06-29 11:37 ranran1203 阅读(692) 评论(0) 推荐(0)
摘要:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number. An example is the root-to-leaf path1->2->3which re 阅读全文
posted @ 2016-06-29 10:35 ranran1203 阅读(184) 评论(0) 推荐(0)
摘要:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'. A region is captured by flipping all'O's into'X's in that surrounded regio 阅读全文
posted @ 2016-06-29 09:49 ranran1203 阅读(232) 评论(0) 推荐(0)
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning 阅读全文
posted @ 2016-06-28 17:41 ranran1203 阅读(278) 评论(0) 推荐(0)
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For exampl 阅读全文
posted @ 2016-06-28 15:27 ranran1203 阅读(293) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solut 阅读全文
posted @ 2016-06-15 13:32 ranran1203 阅读(223) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solut 阅读全文
posted @ 2016-06-15 12:51 ranran1203 阅读(1241) 评论(0) 推荐(0)
摘要:1.前序遍历 对于任一结点P: 1)访问结点P,并将结点P入栈; 2)判断结点P的左孩子是否为空,若为空,则取栈顶结点并进行出栈操作,并将栈顶结点的右孩子置为当前的结点P,循环至1);若不为空,则将P的左孩子置为当前的结点P; 3)直到P为NULL并且栈为空,则遍历结束。 1)若其左孩子不为空,则将 阅读全文
posted @ 2016-06-15 10:50 ranran1203 阅读(186) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solut 阅读全文
posted @ 2016-06-14 17:26 ranran1203 阅读(243) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solut 阅读全文
posted @ 2016-06-14 15:38 ranran1203 阅读(188) 评论(0) 推荐(0)