F_G

许多问题需要说清楚就可以&&走永远比跑来的重要

导航

上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 23 下一页

2015年8月17日 #

[Leetcode] Pascal's Triangle II

摘要: Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(... 阅读全文

posted @ 2015-08-17 11:11 F_G 阅读(152) 评论(0) 推荐(0) 编辑

[Leetcode] Largest Number

摘要: 再次熟悉java当中的comparator的写法Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9]... 阅读全文

posted @ 2015-08-17 10:24 F_G 阅读(147) 评论(0) 推荐(0) 编辑

[Leetcode] binary tree 右视问题

摘要: [1] Populating Next Right Pointers in Each Node[2] Populating Next Right Pointers in Each Node II[3] Binary Tree Right Side View一、参考我的另一篇博客二、同一三、使用层次遍... 阅读全文

posted @ 2015-08-17 10:10 F_G 阅读(176) 评论(0) 推荐(0) 编辑

2015年8月16日 #

[Leetcode] 旋转问题(旋转数组的查找,旋转list,旋转矩阵)

摘要: [1] Search in Rotated Sorted Array在二分查找问题当中,对于边界的查找,尤其是==的情况应该放到左边界上,因为对于mid的求取又是就是left,所以这是检测应该是true,所以下面的nums[mid]>=nums[left],如果改为nums[mid]>nums[le... 阅读全文

posted @ 2015-08-16 11:29 F_G 阅读(481) 评论(0) 推荐(0) 编辑

[Leetcode] 回文问题

摘要: [1] Palindrome Number[2] Valid Palindrome[3] Palindrome Partitioning[4] Palindrome Partitioning II[5] Shortest Palindrome[6] Palindrome Linked List[7]... 阅读全文

posted @ 2015-08-16 11:08 F_G 阅读(326) 评论(0) 推荐(0) 编辑

[Leetcode] Word Ladder I,II

摘要: 一、问题描述:Given:start="hit"end="cog"dict=["hot","dot","dog","lot","log"]As one shortest transformation is"hit" -> "hot" -> "dot" -> "dog" -> "cog",return... 阅读全文

posted @ 2015-08-16 11:00 F_G 阅读(238) 评论(0) 推荐(0) 编辑

2015年8月15日 #

[Leetcode] Best Time to Buy and Sell Stock I,II,III,IV

摘要: 三种股票交易算法一、交易次数没有限制使用贪心策略,找最长递增序列,同时累加相应利润。二、只有一次交易使用动态规划算法,从前往后,依次记记录相应时间节点前面的最小price,同时获得在这个节点的最大利润,同时更新最小price三、最多两次使用两次动态规划1、从左向右,记录在相应的时间节点卖出的最大利润... 阅读全文

posted @ 2015-08-15 18:55 F_G 阅读(191) 评论(0) 推荐(0) 编辑

[Leetcode] Populating Next Right Pointers in Each Node I,II

摘要: 这两个题目使用相同的code就可以解决。算法在每一层遍历当中记录head节点,那么在下一层的遍历当中就可以使用这个head遍历整层,同时记录下层的head,依次类推,直到head为空,表示到达了最底层。 阅读全文

posted @ 2015-08-15 18:50 F_G 阅读(107) 评论(0) 推荐(0) 编辑

[Leetcode] Construct Binary Tree from Inorder and Postorder Traversal I,II

摘要: 这两个问题实际上是同一个问题,需要对三种遍历方式的规律非常清楚。对于前序遍历,第一个元素实际上就是root,然后后面的元素前半部分是左树的node,后半部分是右树的node对于中序遍历,一旦我们知道了root节点,那么就可以将其分为两半部分,也就是左树和右树对于后序遍历,我们可以缺点最后一个节点是r... 阅读全文

posted @ 2015-08-15 18:47 F_G 阅读(115) 评论(0) 推荐(0) 编辑

[Leetcode] Convert Sorted List to Binary Search Tree

摘要: 对于Convert Sorted array to Binary Search Tree相对简单,使用二分的方式就可以确定左树和右树的范围。一、对于此问题,使用二分的方式也是可以的,但是没有数组的随机访问的特性,需要遍历数组找到list的中间node。为了便于查找中间node可以首先统计节点的个数。... 阅读全文

posted @ 2015-08-15 18:25 F_G 阅读(168) 评论(0) 推荐(0) 编辑

上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 23 下一页