摘要: https://leetcode.com/problems/guess-number-higher-or-lower/ 阅读全文
posted @ 2016-07-14 13:29 blcblc 阅读(264) 评论(0) 推荐(0) 编辑
摘要: // https://discuss.leetcode.com/topic/50527/java-10ms-solution-no-priority-queue class Solution { public: vector> kSmallestPairs(vector& nums1, vector& nums2, int k) { sort(nums1.begin()... 阅读全文
posted @ 2016-07-10 15:00 blcblc 阅读(205) 评论(0) 推荐(0) 编辑
摘要: // https://discuss.leetcode.com/topic/50489/c-clean-and-short-solution class Solution { int base = 1337; int powMod(int a, int b) { a %= base; int result = 1; for (in... 阅读全文
posted @ 2016-07-10 14:10 blcblc 阅读(187) 评论(0) 推荐(0) 编辑
摘要: // refer to // https://leetcode.com/discuss/111582/java-simple-easy-understand-solution-with-explanation class Solution { public: int getSum(int a, int b) { //int tmp_sum = a ^ b; // a x... 阅读全文
posted @ 2016-06-30 17:31 blcblc 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 用了两种方法: 31 / 31 test cases passed. Accepted Runtime: 261 ms 开始用的下面这种方法,超时了: 阅读全文
posted @ 2016-06-28 14:30 blcblc 阅读(669) 评论(0) 推荐(0) 编辑
摘要: 这道题目的循环里面的那个递推的式子很巧妙,能够帮助循环快速收敛。 阅读全文
posted @ 2016-06-27 15:06 blcblc 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 以下这个解法也是参考了一些讨论: https://leetcode.com/discuss/110235/c-solution-using-euclidean-algorithm 还有这个解释原理的,没有看懂:https://leetcode.com/discuss/110525/a-little- 阅读全文
posted @ 2016-06-27 14:45 blcblc 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 根据上一篇文章提到的参考文档: https://leetcode.com/discuss/109749/accepted-c-codes-with-explanation-and-references 我实现的解法,用了一个sum_max,不再另设res。 27 / 27 test cases pa 阅读全文
posted @ 2016-06-27 14:22 blcblc 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 今天的一道题目: https://leetcode.com/problems/max-sum-of-sub-matrix-no-larger-than-k/ 有难度。这一类题目很有代表性。 搜到这个网址有针对一维数组的求和的按照时间复杂度一步步优化的过程,讲的很不错: http://www.cnbl 阅读全文
posted @ 2016-06-27 13:39 blcblc 阅读(974) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/count-numbers-with-unique-digits/ class Solution { public: int countNumbersWithUniqueDigits(int n) { if (n < 1) { return 1; } ... 阅读全文
posted @ 2016-06-15 16:42 blcblc 阅读(230) 评论(0) 推荐(0) 编辑