2018年9月8日

course schedule 2 bfs indegree

摘要: bfs indegree Pretty much the same as the course schedule 1 The only diff is to return the order of the classes, which we can use a list as a container 阅读全文

posted @ 2018-09-08 10:50 猪猪🐷 阅读(113) 评论(0) 推荐(0)

course schedule 1 bfs indegree

摘要: Use bfs The given is [[1,0]] To take course 1 you should have finished course 0. So it is possible. So we need to convert the input into something lik 阅读全文

posted @ 2018-09-08 10:41 猪猪🐷 阅读(95) 评论(0) 推荐(0)

decode ways

摘要: // dfs class Solution { public int numDecodings(String s) { if(s == null || s.length() == 0) return 0; return dfs(s, 0); } private int dfs(String s, int i){ if(i ... 阅读全文

posted @ 2018-09-08 07:33 猪猪🐷 阅读(124) 评论(0) 推荐(0)

word break

摘要: // Time complexity : O(n^2)// Two loops are their to fill dp array. //Space complexity : O(n). Length of pp array is n+1 阅读全文

posted @ 2018-09-08 07:07 猪猪🐷 阅读(153) 评论(0) 推荐(0)

inorder successor bst

摘要: Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in-order successor in 阅读全文

posted @ 2018-09-08 04:35 猪猪🐷 阅读(119) 评论(0) 推荐(0)

inorder predecessor bst

摘要: Bst inorder successor/ predecessore With parent pointer, without parent pointer Iterative, recursive ======================================= Predecessor with a parent pointer (iterative) idea: ... 阅读全文

posted @ 2018-09-08 04:34 猪猪🐷 阅读(251) 评论(0) 推荐(0)

导航