JasonChang

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 18 下一页

2013年11月11日

摘要: 将左子树移到右边循环即可 1 public class Solution { 2 public void flatten(TreeNode root) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 while(root != null){ 6 if(root.left != null){ 7 ... 阅读全文
posted @ 2013-11-11 15:39 JasonChang 阅读(159) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public int numDistinct(String S, String T) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 if(S == null || S.length() == 0){ 6 return 0; 7 ... 阅读全文
posted @ 2013-11-11 15:19 JasonChang 阅读(165) 评论(0) 推荐(0) 编辑

摘要: 先遍历右子树 1 public class Solution { 2 public void connect(TreeLinkNode root) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 if(root == null) 6 return; 7 8 T... 阅读全文
posted @ 2013-11-11 14:39 JasonChang 阅读(165) 评论(0) 推荐(0) 编辑

摘要: recursion programming画图看特点 1 public class Solution { 2 public void connect(TreeLinkNode root) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 if(root == null) 6 return; 7 ... 阅读全文
posted @ 2013-11-11 14:19 JasonChang 阅读(186) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public ArrayList getRow(int rowIndex) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 ArrayList previous = new ArrayList(); 6 ArrayList result = new A... 阅读全文
posted @ 2013-11-11 14:05 JasonChang 阅读(145) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public ArrayList> generate(int numRows) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 ArrayList> result = new ArrayList>(); 6 if(numRows == 0) 7 ... 阅读全文
posted @ 2013-11-11 13:48 JasonChang 阅读(154) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public int minimumTotal(ArrayList> triangle) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 int length = triangle.size(); 6 int[] result = new int[le... 阅读全文
posted @ 2013-11-11 13:12 JasonChang 阅读(195) 评论(0) 推荐(0) 编辑

摘要: 前后两遍遍历,算出当前位置之前和之后的最大利润。 1 public class Solution { 2 public int maxProfit(int[] prices) { 3 4 if(prices == null || prices.length == 0) 5 return 0; 6 7 int[] max = new int[prices.length]; 8 int min = prices[0]; 9 int result = 0;10 ... 阅读全文
posted @ 2013-11-11 12:56 JasonChang 阅读(183) 评论(0) 推荐(0) 编辑

摘要: 注意各种数据结构的特点,删除的时候要注意遍历 1 public class Solution { 2 public int ladderLength(String start, String end, HashSet dict) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 6 LinkedList qu... 阅读全文
posted @ 2013-11-11 10:14 JasonChang 阅读(204) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public void solve(char[][] board) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 if(board == null||board.length == 0||board[0] == null||board[0].length == 0)... 阅读全文
posted @ 2013-11-11 09:20 JasonChang 阅读(194) 评论(0) 推荐(0) 编辑

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 18 下一页