摘要: 1 public class Solution { 2 private int[] parent; 3 public int countComponents(int n, int[][] edges) { 4 if (edges.length == 0) { 5 return n; 6 } 7 ... 阅读全文
posted @ 2016-07-02 07:06 keepshuatishuati 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 1. Use backward arrangement in case of [4, 5, 5, 6]. 阅读全文
posted @ 2016-07-02 06:56 keepshuatishuati 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 1 public class Solution { 2 public boolean isPowerOfThree(int n) { 3 while (n > 1) { 4 if (n % 3 != 0) { 5 return false; 6 } 7 n... 阅读全文
posted @ 2016-07-02 05:58 keepshuatishuati 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 1. Do not mess it up with number of islands. Each path extends only choose one. 阅读全文
posted @ 2016-07-02 05:13 keepshuatishuati 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 1. Use the condition : he/she knows no one. So you can get candidate by filtering out whether a candidate knows somebody. 2. Use the condition : all o 阅读全文
posted @ 2016-07-02 03:10 keepshuatishuati 阅读(143) 评论(0) 推荐(0) 编辑