上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页
摘要: When we get this problem, we need to confirm the following 2 questions: 1. Can root, p or q be null? (No) 2. Are both p and q in the tree (No, either 阅读全文
posted @ 2022-02-08 07:36 阳光明媚的菲越 阅读(18) 评论(0) 推荐(0) 编辑
摘要: When we get this problem, we need to confirm the following 3 questions: 1. Can root, p or q be null? (No) 2. Are both p and q in the tree (yes) 3. Can 阅读全文
posted @ 2022-02-08 06:30 阳光明媚的菲越 阅读(15) 评论(0) 推荐(0) 编辑
摘要: Although this is an easy question, but it is prone to bugs, and the code can be better. Following is my first solution, didn't use the feature of BST. 阅读全文
posted @ 2022-02-08 04:38 阳光明媚的菲越 阅读(17) 评论(0) 推荐(0) 编辑
摘要: For sparse venctors, there might be too many "0"s in the array. What we need to do is only abstract the items which are not "0". We store these non-ze 阅读全文
posted @ 2022-02-08 04:13 阳光明媚的菲越 阅读(26) 评论(0) 推荐(0) 编辑
摘要: My first solution is use two skacks, one stack store index, another one store value, the time complexity is O(n). public int[] findBuildings(int[] hei 阅读全文
posted @ 2022-02-08 01:29 阳光明媚的菲越 阅读(41) 评论(0) 推荐(0) 编辑
摘要: My first version brute force solution just switch the chars one by one and compare with the max value. The time complaxity is O(n2). public int maximu 阅读全文
posted @ 2022-02-07 15:02 阳光明媚的菲越 阅读(23) 评论(0) 推荐(0) 编辑
摘要: When I got this problem, I used one Deque and one map to solve it, the solution is as following, the time complexity of get() and put() is O(n), n is 阅读全文
posted @ 2022-02-07 11:31 阳光明媚的菲越 阅读(31) 评论(0) 推荐(0) 编辑
摘要: For this problem, if don't consider the follow up limitation, the solution is very easy: The time complexity is O(1), the space complexity is O(n), n 阅读全文
posted @ 2022-02-06 12:07 阳光明媚的菲越 阅读(20) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2022-02-05 12:07 阳光明媚的菲越 阅读(0) 评论(0) 推荐(0) 编辑
摘要: When we met path or parentheses problems, always think about Stack first. For this problem, only three conditions need to be considered: 1. the substr 阅读全文
posted @ 2022-02-05 09:54 阳光明媚的菲越 阅读(24) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页