Other articles

  1. 150 Years of Sun Yat-sen

    孙中山先生诞辰 150 周年

    实际上我对于孙先生的生平并不十分了解,很多所知都是来自于影视剧中的片段。 不过,总还是有些感慨:150年了呢,孙先生所在的那个时代,不在其中难以想象其动荡, 但总是会感觉,即便身在现在,自己有看到现在的时代潮流和未来走向吗? 自觉不能。所以,十分佩服,在时代中看准方向,坚持,妥协,不屈,探索,走完自己不悔的一生。

    read more
  2. LeetCode: 421. Maximum XOR of Two Numbers in an Array

    The problem is https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/. If just follow the process defined as described in problem, it is quite simple except the runtime is O(n**2):

    class Solution(object):
        def findMaximumXOR(self, nums):
            :type nums: List[int]
            :rtype: int
            if len(nums)<2:
                return 0
            ret = nums ...
    read more
  3. LeetCode: 401. Binary Watch

    The problem is https://leetcode.com/problems/binary-watch/. Because the input size is limited, generating every output is workable. Simplely follow the input, using itertools could generate all combinations.

    import itertools
    digitals = [8, 4, 2, 1, 32, 16, 8, 4, 2, 1]
    def get_xtime(ps):
        h = 0
        m = 0
        for ...
    read more
  4. The ThinkPad X60/61 Series Are Really Classical

    Recently I received an old ThinkPad X61 body, which has a broken screen, lacks battery, bad memory, slow hdd and broken surface C. After bought some accessories, I re-installed a Xubuntu 16.04 system on it. Even at present, the design of this laptop is in fashion. All four borders ...

    read more
  5. LeetCode: 195. Tenth Line

    The problem is here: https://leetcode.com/problems/tenth-line/. It's a bash programming, reading the 10th line of a file and output in stdout. I think there are lots of methods to do this, here I write some.

    If the file has more than 10 lines, I can output ...

    read more
  6. LeetCode: 112. Path Sum

    The problem is here: https://leetcode.com/problems/path-sum/ . Fancy that the number can be negative numbers, I made a stupid 'optimization'. I added a piece of code to check whether current node value is bigger than sum, assuming that every node value is positive. After droping this 'optimization', it ...

    read more
  7. LeetCode: 201. Bitwise AND of Numbers Range

    The problem is here: https://leetcode.com/problems/bitwise-and-of-numbers-range/ . I simply wrote a silly version and failed as expected, it just did exactly as this problem described.

    class Solution(object):
        def rangeBitwiseAnd(self, m, n):
            Attention! This is a bad version!
            :type m: int
            :type n: int
            :rtype: int
            return ...
    read more
  8. Nintendo Switch was Announced!

    March 2017! Begin to save money~ The price maybe $299.99, I can save $60 each month! Till the end of March 2017, I will get $300!

    But, I have a problem...Can I buy one in origin price here? It may not on sale in China...maybe taobao is ...

    read more
  9. LeetCode: 235. Lowest Common Ancestor of a Binary Search Tree

    The problem is here: https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/ . Using recursive function solve this fast, because of the nature of BST. For each node in BST, every node on left is smaller than root and every node on right. Therefore, the ancestor of two nodes in BST must be a ...

    read more

Page 1 / 4 »