摘要: problem:https://leetcode.com/problems/minimum-domino-rotations-for-equal-row/ 有四种可能性,相等数字为A[0],出现在上面或下面;相等数字为B[0],出现在上面或下面。取这四者最小值即可。 阅读全文
posted @ 2019-08-03 20:04 fish1996 阅读(138) 评论(0) 推荐(0)
摘要: problem:https://leetcode.com/problems/construct-quad-tree/ 一道简单的建树题目,模拟即可。 阅读全文
posted @ 2019-08-03 19:02 fish1996 阅读(156) 评论(0) 推荐(0)
摘要: problem: https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/ O(n2), 把已有的a + b = c 结果用hashmap存起来,然后计算当前数字为结尾的最长类斐波那契子序列。 其中,dp[i][j] 阅读全文
posted @ 2019-08-03 18:11 fish1996 阅读(169) 评论(0) 推荐(0)
摘要: problem:https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/ 暴力枚举了一下所有子字符串可能对应的数字,统计是否达到N个,就过了。不知道有没有更快的方法。 阅读全文
posted @ 2019-08-03 17:14 fish1996 阅读(132) 评论(0) 推荐(0)
摘要: problem:https://leetcode.com/problems/knight-dialer 可能是一个比较蠢的dp做法,因为我手动把跳转的方法写成了表: 阅读全文
posted @ 2019-08-03 17:04 fish1996 阅读(268) 评论(0) 推荐(0)
摘要: problem: 一道模拟题,用深搜匹配一下所有情况即可。 阅读全文
posted @ 2019-08-03 14:52 fish1996 阅读(212) 评论(0) 推荐(0)
摘要: problem:https://leetcode.com/problems/car-fleet/ 按位置对车进行排序,然后从后往前扫描,判断当前车能否被后面一辆车超越(比较后面的车达到终点用的时间是否更短),如果能,以当前这辆车为基础,再判断下一辆后面的车能否超越它;否则以后面一辆车作为新的比较标准 阅读全文
posted @ 2019-08-03 10:55 fish1996 阅读(168) 评论(0) 推荐(0)