2018年2月7日

leetcode 263. Ugly Number

摘要: bool isUgly(int num) { while (num < 1) return false; while (num % 2 == 0) num /= 2; while (num % 3 == 0) num /= 3; while (num %... 阅读全文

posted @ 2018-02-07 15:00 willaty 阅读(76) 评论(0) 推荐(0) 编辑

leetcode 258. Add Digits

摘要: 给个整数,每位相加,如果位数大于1,重复,知道剩一位。 附加要求:要求不用递归循环,O(1)。 看到这要求,肯定有规律: - D,从10开始推,一下子就看出来了。 阅读全文

posted @ 2018-02-07 14:09 willaty 阅读(80) 评论(0) 推荐(0) 编辑

leetcode 257. Binary Tree Paths

摘要: 返回所有根到叶子的路径。用个“全局”的ret代替合的过程。 阅读全文

posted @ 2018-02-07 13:29 willaty 阅读(74) 评论(0) 推荐(0) 编辑

leetcode 242. Valid Anagram

摘要: 哈希。 阅读全文

posted @ 2018-02-07 11:15 willaty 阅读(97) 评论(0) 推荐(0) 编辑

导航