摘要:
如果你碰到排列组合的题,就想想是否可以用backtracking做,然后把模版记住: private List<List<Integer>> res = new ArrayList<>(); public List<List<Integer>> subsets(int[] nums) { backt 阅读全文
摘要:
Solution 1: Union-Found private int[] root; private int count; public boolean validTree(int n, int[][] edges) { count = n; if(edges.length!=n-1) retur 阅读全文
摘要:
I have originally write a BFS solution for this problem, but it seems too difficlut. And then I read other's code, found that solution is much easier. 阅读全文
摘要:
Take the following nums as an exmpel : [2,4,3,1] The 4, 3, 1 is a decending order, it cannot be larger any more. How we can make 2,4,3,1 larger? we ne 阅读全文
摘要:
This problem is very easy to solve if using bruteforece solution, the time complexity is O(n). public double myPow(double x, int n) { if (n == 0) retu 阅读全文
摘要:
This is two points problem, just concentrate and carefully deal with the characters, then the problem can be solved. This is a very good problem for w 阅读全文
摘要:
This is the same problem with https://www.cnblogs.com/feiflytech/p/15862380.html public int[][] generateMatrix(int n) { int[][] matrix = new int[n][n] 阅读全文
摘要:
This is an exactly same problem with "59. Spiral Matrix II". I set every direction as a status, when one direction was implemented, the current status 阅读全文