leetcode
文章平均质量分 63
猪小小_up
这个作者很懒,什么都没留下…
展开
-
Leetcode-Sort List
Sort a linked list in O(n log n) time using constant space complexity./** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { *原创 2014-09-20 11:45:13 · 466 阅读 · 0 评论 -
题型分类------字符串和数组(Doing)
1. [1]. Reverse Words in a String:空格的处理2. Evaluate Reverse Polish Notation: 栈3. Single Number II 位运算4. Single Number 位运算5. Longest Common Prefix : 平常的字符串比较6. Regular Expression Matching : 递归原创 2014-11-14 10:53:31 · 545 阅读 · 0 评论 -
Leetcode-Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.题目大衣原创 2014-10-12 11:48:11 · 443 阅读 · 0 评论 -
Leetcode-Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.AC代码:原创 2014-10-12 15:19:20 · 519 阅读 · 0 评论 -
Leetcode-Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is原创 2014-10-11 10:37:54 · 476 阅读 · 0 评论 -
题型分类------其他类(doing)
1. Best Time to Buy and Sell Stock2. Best Time to Buy and Sell Stock II3. Pascal's Triangle4. Roman to Integer5. Integer to Roman6. LRU Cache7. Word Break II8. Word Break: 动态规划9. C原创 2014-11-14 10:55:32 · 552 阅读 · 0 评论 -
题型分析------数字类(done)
1. Palindrome Number2. Add Two Numbers3. Permutations4. Gray Code5. Sqrt(x)6. Plus One7. Valid Number8. Pow(x, n)9. Permutations II10. Divide Two Integers11. 4Sum12. 3Sum Close原创 2014-11-14 10:54:36 · 556 阅读 · 0 评论 -
Leetcode-Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1-原创 2014-10-13 10:31:08 · 485 阅读 · 0 评论 -
Leetcode-Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the l原创 2014-10-13 11:02:06 · 466 阅读 · 0 评论 -
Leetcode-Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.AC代码:原创 2014-10-14 11:20:39 · 419 阅读 · 0 评论 -
Leetcode分类-链表
题型分类------链表一、链表排序1. Sort List: 对一个单链表排序,要求时间复杂度为O(nlogn);2. Insertion Sort List: 用插入法对单链表排序;3. Reorder List: 将一个链表进行交叉排序,比如给一个链表 L: L0→L1→…→Ln-1→Ln,要求排完序后为L0→Ln→L1→Ln-1→L2→Ln-2→原创 2014-09-28 16:39:11 · 466 阅读 · 0 评论 -
Leetcode-Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recursive solutio原创 2014-10-15 12:19:41 · 435 阅读 · 0 评论 -
Leetcode-Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},1\2/3return [1,2,3].Note: Recursive solution is trivial, could you原创 2014-10-15 11:04:24 · 421 阅读 · 0 评论 -
Leetcode-Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y原创 2014-10-14 20:15:05 · 401 阅读 · 0 评论 -
Leetcode-Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solut原创 2014-10-17 11:08:57 · 592 阅读 · 0 评论 -
Leetcode-Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum原创 2014-10-29 10:31:06 · 502 阅读 · 0 评论 -
Leetcode-Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?分析:如图:原创 2014-10-09 22:09:26 · 454 阅读 · 0 评论 -
Leetcode-Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321原创 2014-09-22 10:38:58 · 518 阅读 · 0 评论 -
Leetcode-SingleNumber
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using ext原创 2014-09-12 15:31:58 · 498 阅读 · 0 评论 -
Leetcode-SingleNumberII
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without usi原创 2014-09-12 15:39:49 · 565 阅读 · 0 评论 -
Leetcode-Reorder List
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-09-23 17:37:23 · 583 阅读 · 0 评论 -
Leetcode-Two Sum
Two SumGiven an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the ta原创 2014-09-24 16:43:34 · 537 阅读 · 0 评论 -
Leetcode-Insertion Sort List
Sort a linked list using insertion sort.AC代码:/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x;原创 2014-09-25 17:28:22 · 460 阅读 · 0 评论 -
Leetcode-Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?AC代码:原创 2014-09-28 16:08:44 · 504 阅读 · 0 评论 -
Leetcode-Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7},原创 2014-10-23 09:50:00 · 501 阅读 · 0 评论 -
Leetcode-Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.思路:z原创 2014-10-23 11:03:53 · 585 阅读 · 0 评论 -
Leetcode-Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.原创 2014-10-23 10:50:26 · 519 阅读 · 0 评论 -
Leetcode-Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.原创 2014-10-28 11:22:31 · 475 阅读 · 0 评论 -
Leetcode-Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f原创 2014-10-28 10:39:46 · 535 阅读 · 0 评论 -
Leetcode分类-树
题型分类------树一、树的遍历1. Binary Tree Preorder Traversal: 使用递归和非递归 前序遍历,主要考察非递归;2. Binary Tree Inorder Traversal: 使用递归和非递归 中序遍历,主要考察非递归;3. Binary Tree Postorder Traversal: 使用递归和非递归 后序遍历,主要考察非递归;原创 2014-10-15 09:19:06 · 560 阅读 · 0 评论 -
Leetcode-Reverse Linked List II
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原创 2014-10-10 16:17:20 · 460 阅读 · 0 评论 -
Leetcode-Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20原创 2014-10-22 15:09:14 · 470 阅读 · 0 评论