
leetCode解题报告
文章平均质量分 92
胖虎
vx:ljpzj1216, 11年移动端开发经验,先后在国内大厂就职过,目前在一家公司担任全栈工程师&技术总监,我和朋友长期接软件外包,如果你有web / app / 小程序等软件开发需求,可以联系我
展开
-
leetCode解题报告之Insertion Sort List
package cn.xym.leetcode;class ListNode { public int val; public ListNode next; ListNode(int x) { val = x; next = null; }}public class Solution { public static void main(String[]原创 2014-03-14 00:36:44 · 2257 阅读 · 0 评论 -
leetCode解题报告5道题(一)
5道题目分别是:【Reverse Linked List II】、【Binary Tree Inorder Traversal】、【Merge Two Sorted Lists (关于两个已经排好序的链表的合并)】、【Same Tree】、【Two Sum】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道题的形式呈现!原创 2014-03-23 11:32:00 · 3287 阅读 · 0 评论 -
leetCode解题报告之O(n)线性时间求最大子序列和(Maximum Subarray)
详细讲解关于求最大子序列和(Maximum Subarray)的4种解法,并分析它们的时间复杂度!O(n^3)->>> O(n^2)->>> O(nlogn)->>>O(n)原创 2014-03-25 12:09:53 · 4218 阅读 · 0 评论 -
leetCode解题报告之Gas Station
题目:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from stat原创 2014-03-26 09:54:12 · 3512 阅读 · 0 评论 -
leetCode解题报告5道题(五)
5道题目分别是:【Path Sum && Path Sum II】、【Merge Sorted Array】、【Flatten Binary Tree to Linked List】、【Distinct Subsequences】、【Symmetric Tree】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道来记录。原创 2014-04-22 20:49:10 · 2019 阅读 · 0 评论 -
leetCode解题报告5道题(四)
5道题目分别是:【Longest Consecutive Sequence】、【Valid Palindrome】、【Binary Tree Maximum Path Sum】、【Reverse Words in a String】、【Unique Binary Search Trees II】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道来记录。原创 2014-04-09 11:05:18 · 2368 阅读 · 0 评论 -
Best Time to Buy and Sell Stock I && II && III
题目1:Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie,原创 2014-05-16 00:21:10 · 2891 阅读 · 1 评论 -
leetCode解题报告5道题(八)
5道题目分别是:【Triangle】、【Pascal's Triangle】、【Pascal's Triangle II 】、【Populating Next Right Pointers in Each Node 】、【Populating Next Right Pointers in Each Node II】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道来记录原创 2014-05-15 14:44:34 · 1729 阅读 · 0 评论 -
leetCode解题报告5道题(十)
5道题目分别是:【Largest Rectangle in Histogram】、【Minimum Path Sum】、【Jump Game】、【Jump Game II 】、【Valid Number】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道来记录。原创 2014-05-19 01:03:08 · 2495 阅读 · 0 评论 -
leetCode解题报告5道题(九)
5道题目分别是:【Combinations】、【Search a 2D Matrix】、【Scramble String 】、【Rotate List 】、【Partition List】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道来记录。原创 2014-05-18 09:57:28 · 2365 阅读 · 1 评论 -
leetCode解题报告5道题(十一)
5道题目分别是:【Subsets】、【Subsets II】、【Unique Paths】、【Unique Paths II】、【Trapping Rain Water 】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道来记录。原创 2014-05-19 23:16:06 · 3001 阅读 · 0 评论 -
leetCode解题报告5道题(七)
5道题目分别是:【Interleaving String】、【Validate Binary Search Tree】、【Sqrt(x) 】、【Recover Binary Search Tree 】、【Climbing Stairs 】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道来记录。原创 2014-05-14 10:03:21 · 2367 阅读 · 0 评论 -
leetCode解题报告5道题(二)
5道题目分别是:【Maximum Depth of Binary Tree】、【Sum Root to Leaf Numbers】、【Unique Binary Search Trees】、【N-Queens && N-Queens II】、【Pow(x, n)】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道题的形式呈现!题目一:Maximum Depth of Binary Tree Given a binary tree, find its maximu原创 2014-04-03 22:24:55 · 3436 阅读 · 0 评论 -
leetCode解题报告5道题(三)
5道题目分别是:【Binary Tree Zigzag Level Order Traversal】、【Convert Sorted Array to Binary Search Tree和Convert Sorted List to Binary Search Tree】、【Surrounded Regions(考察深度搜索)】、【Balanced Binary Tree】、【Minimum Depth of Binary Tree】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道原创 2014-04-04 23:28:40 · 2078 阅读 · 1 评论 -
leetCode解题报告之Sort List
题目:Sort a linked list in O(n log n) time using constant space complexity.分析:题目要求我们要用一个复杂度O(nlogn)的排序算法来排序一个链表,复杂度O(nlogn)的排序算法包括:快速排序,堆排序,希尔排序,二叉排序树排序,归并排序情况:考虑到算法的复杂度,还有需要O(1)的原创 2014-03-16 22:55:38 · 1841 阅读 · 0 评论 -
leetCode解题报告之Binary Tree Postorder Traversal
题目: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 /原创 2014-03-17 08:36:10 · 6961 阅读 · 0 评论 -
leetCode解题报告之Clone Graph
题目:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a sep原创 2014-03-27 16:56:42 · 3221 阅读 · 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}, reo原创 2014-03-18 13:45:14 · 3060 阅读 · 0 评论 -
leetCode解题报告之Binary Tree Level Order Traversal II,I(二叉树层次遍历)
题目:Binary Tree Level Order Traversal II(由于Binary Tree Level Order Traversal I 这个题目只是在II的基础上少了一步最后的翻转result list而已,所以我就不贴出它的代码了)Given a binary tree, return thebottom-up level ordertraversal of...原创 2014-03-28 20:28:01 · 15853 阅读 · 1 评论 -
leetCode解题报告之Palindrome Partitioning I,II(DFS,DP)
题目:Palindrome PartitioningIGiven a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For examp...原创 2014-03-31 01:02:53 · 22293 阅读 · 1 评论 -
leetCode解题报告之Copy List with Random Pointer
题目:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.分析:我们知道如果是简单的copy Lis原创 2014-03-22 23:08:40 · 3842 阅读 · 0 评论 -
leetCode解题报告之SingleNumberI,II(知识点:位运算)
由于两题是姐妹题,所以放在同一个博文里了!题目1: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. Cou原创 2014-03-23 00:40:11 · 3298 阅读 · 0 评论 -
leetCode解题报告之构造二叉树(递归)
此博文主要讲述了构造二叉树的两种方法:1、通过先序和中序构造出二叉树( 来自leetCode OJ上的 题目:Construct Binary Tree from Preorder and Inorder Traversal )2、通过后序和中序构造出二叉树( 来自leetCode OJ上的 题目:Construct Binary Tree from Inorder and Po原创 2014-03-25 19:50:20 · 4380 阅读 · 0 评论 -
leetCode解题报告之Candy(简单回溯)
题目:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at原创 2014-03-26 08:52:32 · 3178 阅读 · 0 评论 -
leetCode: Word Break I & Word Break II
题目:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict =原创 2014-03-20 20:10:29 · 5937 阅读 · 0 评论 -
leetCode解题报告5道题(六)
5道题目分别是:【Longest Substring Without Repeating Characters】、【Rotate Image】、【Restore IP Addresses】、【ZigZag Conversion】、【Set Matrix Zeroes】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道来记录原创 2014-04-29 00:40:24 · 2627 阅读 · 0 评论