11 2014 档案

快速排序
摘要:1.快速排序是分治算法,所以用递归比较好实现2.每一躺排序开始时,用low,high控制排序,当low = end){ return; } while(low = mid) { //这里加不加等号都不影响排序的结果,下面一样 --high; ... 阅读全文

posted @ 2014-11-29 22:47 远近闻名的学渣 阅读(130) 评论(0) 推荐(0)

leetcode : Minimum Window Substring
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA... 阅读全文

posted @ 2014-11-29 21:45 远近闻名的学渣 阅读(148) 评论(0) 推荐(0)

leetcode : Search a 2D Matrix
摘要:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... 阅读全文

posted @ 2014-11-28 22:39 远近闻名的学渣 阅读(178) 评论(1) 推荐(0)

leetcode : Set Matrix Zeroes
摘要:Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.Follow up:Did you use extra space?A straight forward solution... 阅读全文

posted @ 2014-11-28 22:14 远近闻名的学渣 阅读(158) 评论(0) 推荐(0)

leetcode : Largest Rectangle in Histogram
摘要:Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histog... 阅读全文

posted @ 2014-11-28 11:30 远近闻名的学渣 阅读(180) 评论(0) 推荐(0)

homebrew 常用命令
摘要:转自http://my.oschina.net/gujianhan/blog/203704查看brew的帮助brew –help安装软件brew install git卸载软件brew uninstall git搜索软件brew search git显示已经安装软件列表brew list更新软件,把... 阅读全文

posted @ 2014-11-27 20:25 远近闻名的学渣 阅读(133) 评论(0) 推荐(0)

初始化与构造函数
摘要:1 c++的内置类型只有int ,double ,long,char等,并不包括string,string是stl定义的一个类2 在没有任何显式的初始化时,编译器会执行默认初始化:对于类类型,由类自己定义默认初始化时的操作,对于内置类型,内置类型的数组,或者指针,如果是全局变量或者静态局部变量,... 阅读全文

posted @ 2014-11-27 18:39 远近闻名的学渣 阅读(259) 评论(0) 推荐(0)

leetcode : Sqrt(x)
摘要:Implementint sqrt(int x).Compute and return the square root ofx.只要返回int值,用二分查找,但是整型会溢出,更坑爹的是,当你发生溢出的时候提示的是超时。。。。。所以用除法而不用乘法AC代码:class Solution {public... 阅读全文

posted @ 2014-11-27 12:34 远近闻名的学渣 阅读(141) 评论(0) 推荐(0)

leetcode : Combinations
摘要:Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],... 阅读全文

posted @ 2014-11-27 11:23 远近闻名的学渣 阅读(107) 评论(0) 推荐(0)

leetcode : Word Search
摘要:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjace... 阅读全文

posted @ 2014-11-26 21:39 远近闻名的学渣 阅读(172) 评论(0) 推荐(0)

leetcode : Partition List
摘要:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文

posted @ 2014-11-26 14:14 远近闻名的学渣 阅读(127) 评论(0) 推荐(0)

leetcode : Scramble String
摘要:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation... 阅读全文

posted @ 2014-11-25 21:56 远近闻名的学渣 阅读(133) 评论(0) 推荐(0)

leetcode : Merge Sorted Array
摘要:Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal... 阅读全文

posted @ 2014-11-25 09:42 远近闻名的学渣 阅读(113) 评论(0) 推荐(0)

二叉树的遍历(非递归方法)
摘要:1.preorderTraversal由于先序遍历无需存储根节点的指针,可以很简单的设置这一个栈,当栈不空时弹出一个节点,访问,然后分别将左右子树压栈即可。下面是第二种方法,模拟了递归的过程;代码:void preorder(TreeNode * root){ auto p = root; ... 阅读全文

posted @ 2014-11-25 09:36 远近闻名的学渣 阅读(245) 评论(0) 推荐(0)

leetcode : Decode Ways
摘要:A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message conta... 阅读全文

posted @ 2014-11-25 09:24 远近闻名的学渣 阅读(162) 评论(0) 推荐(0)

leetcode : Unique Binary Search Trees I&II
摘要:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's.I是要求... 阅读全文

posted @ 2014-11-25 09:10 远近闻名的学渣 阅读(162) 评论(0) 推荐(0)

leetcode : Reverse Linked List II
摘要:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No... 阅读全文

posted @ 2014-11-24 17:23 远近闻名的学渣 阅读(117) 评论(0) 推荐(0)

leetcode : Interleaving String
摘要:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="... 阅读全文

posted @ 2014-11-24 15:03 远近闻名的学渣 阅读(168) 评论(0) 推荐(0)

leetcode : Validate Binary Search Tree
摘要:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n... 阅读全文

posted @ 2014-11-24 10:32 远近闻名的学渣 阅读(139) 评论(0) 推荐(0)

leetcode : Recover Binary Search Tree
摘要:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ... 阅读全文

posted @ 2014-11-24 09:32 远近闻名的学渣 阅读(170) 评论(0) 推荐(0)

leetcode : Construct Binary Tree from Inorder and Postorder Traversal
摘要:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.使用分治算法可以很好的解决,... 阅读全文

posted @ 2014-11-23 21:32 远近闻名的学渣 阅读(139) 评论(0) 推荐(0)

leetcode : Convert Sorted List to Binary Search Tree
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.使用分治的思想很好解决的问题。难点有两个,1如何建立平衡二叉搜索树,2,所给的单链... 阅读全文

posted @ 2014-11-23 18:54 远近闻名的学渣 阅读(137) 评论(0) 推荐(0)

leetcode : Subsets I&II
摘要:Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.... 阅读全文

posted @ 2014-11-22 20:34 远近闻名的学渣 阅读(100) 评论(0) 推荐(0)

leetcode : Maximum Product Subarray
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文

posted @ 2014-11-21 22:46 远近闻名的学渣 阅读(120) 评论(0) 推荐(0)

leetcode : Balanced Binary Tree
摘要:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文

posted @ 2014-11-20 19:32 远近闻名的学渣 阅读(180) 评论(0) 推荐(1)

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 le... 阅读全文

posted @ 2014-11-20 14:27 远近闻名的学渣 阅读(135) 评论(0) 推荐(1)

leetcode : Distinct Subsequences
摘要:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig... 阅读全文

posted @ 2014-11-20 13:57 远近闻名的学渣 阅读(179) 评论(1) 推荐(0)

导航