摘要: 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 阅读全文
posted @ 2022-02-04 05:56 阳光明媚的菲越 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2022-02-04 04:33 阳光明媚的菲越 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2022-02-04 03:07 阳光明媚的菲越 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 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] 阅读全文
posted @ 2022-02-04 02:34 阳光明媚的菲越 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2022-02-04 02:32 阳光明媚的菲越 阅读(26) 评论(0) 推荐(0) 编辑
摘要: I firstly solved this problem bruteforcely, the solution is easy, but the time complexity is O(n2): public int[] dailyTemperatures(int[] temperatures) 阅读全文
posted @ 2022-02-03 14:31 阳光明媚的菲越 阅读(23) 评论(0) 推荐(0) 编辑
摘要: This is a "palindromic" problem, I think DP can solve this problem, but there is a easier way to solve it, the time complexity is O(n2): private int r 阅读全文
posted @ 2022-02-03 10:32 阳光明媚的菲越 阅读(17) 评论(0) 推荐(0) 编辑
摘要: This is the similar problem with "31. Next Permutation", the differences are: 1. 31 don't care about whether the "next" is larger or not, but 556 care 阅读全文
posted @ 2022-02-03 08:01 阳光明媚的菲越 阅读(22) 评论(0) 推荐(0) 编辑
摘要: This problem can be resolved by two points, but the operation is pretty tricky: public List<List<Integer>> findRLEArray(int[][] encoded1, int[][] enco 阅读全文
posted @ 2022-02-03 07:53 阳光明媚的菲越 阅读(37) 评论(0) 推荐(0) 编辑
摘要: This is an absolutely math problem: 1. calculate minute angle: 360/60*minutes 2. calculate hour angle: 360/12*hour%12 3. calculate hour angle's plus, 阅读全文
posted @ 2022-02-03 04:28 阳光明媚的菲越 阅读(30) 评论(0) 推荐(0) 编辑