自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(16)
  • 收藏
  • 关注

原创 ddd

Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy the following condi

2014-01-27 14:46:26 135

原创 Binary Tree Zigzag Level Order Traversal (LeetCode)

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary

2014-01-27 13:10:35 405

原创 Convert Sorted List to Binary Search Tree (LeetCode)

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.用start和end两个point来记录当前的sublist,每次取中间值create new TreeNode后,用递归分别创建left subtree和right subtr

2014-01-27 12:57:39 545

原创 Path Sum II (LeetCode)

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \

2014-01-27 11:58:16 422

原创 Flatten Binary Tree to Linked List (LeetCode)

Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1

2014-01-27 11:43:49 355

原创 Populating Next Right Pointers in Each Node II (LeetCode)

Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant

2014-01-27 11:16:34 382

原创 Distinct Subsequences (LeetCode)

Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non

2014-01-27 10:01:27 362

原创 Edit Distance (LeetCode)

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:

2014-01-27 09:08:58 371

原创 Binary Tree Maximum Path Sum (LeetCode)

Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return 6

2014-01-26 12:50:37 502

原创 Word Ladder (LeetCode)

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word m

2014-01-26 12:23:50 424

原创 Longest Consecutive Sequence (LeetCode)

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 consecutive elements sequence is [1, 2, 3

2014-01-26 12:07:36 367

原创 Palindrome Partitioning (LeetCode)

Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","b"],

2014-01-26 11:51:11 388

原创 Reorder List (LeetCode)

Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to 

2014-01-26 07:39:57 334

原创 Sort List (LeetCode)

Sort a linked list in O(n log n) time using constant space complexity.看到 O(nlogn)第一想到的是merge sort,这里采用的是每次merge前遍历当前list,找到中间节点,然后对head和中间节点分别再进行sort,再merge。或者也可以用两个point,start和end,当start==end

2014-01-26 07:12:54 429

原创 Evaluate Reverse Polish Notation (LeetCode)

用了stack,遍历数组,遇到数字就push,遇到运算符,取出stack中最近入栈的两个数进行计算,然后继续入栈。最后return stack中的结果即可public int evalRPN(String[] tokens) { if(tokens.length==0) return 0; Stack stack = new

2014-01-26 07:09:05 407

原创 Insertion Sort List (LeetCode)

public ListNode insertionSortList(ListNode head) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case.

2014-01-26 07:04:05 422

空空如也

空空如也

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

TA关注的人

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