原创 ImportError: Python is not installed as a framework

ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly i

原创 python import導入模塊

regular imports 常規導入 use from to import relative imports 相對導入 optional imports 可選導入 local imports 本地導入 import con

原创 03.使用私有構造方法或者枚舉類型實現單例Singleton屬性【Effective Java】

Character 2 Creating and Destroying objects 使用私有構造方法或者枚舉類型執行單例singleton屬性 文章目錄問題場景方法一:公共屬性 public field方法二:靜態工廠方法方法

原创 樹的子結構[劍指offer]之python實現

題目描述 輸入兩棵二叉樹A,B,判斷B是不是A的子結構。(ps:我們約定空樹不是任意一個樹的子結構) 題目鏈接 # -*- coding:utf-8 -*- # class TreeNode: # def __init__

原创 Leetcode Matchsticks to Square 473

Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, pleas

原创 Leetcode Number of Segments in a String 434

Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space chara

原创 Leetcode Add Strings 415

Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. Note: The leng

原创 Leetcode Number of Boomerangs 447

Given n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that

原创 Leetcode Counting Bits 338

Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s i

原创 Leetcode Best Time to Buy and Sell Stock

dp練習: 1. Input: [7, 1, 5, 3, 6, 4] Output: 5 max. difference = 6-1 = 5 (not 7-1 = 6, as selling price needs to be

原创 Leetcode Total Hamming Distance 477

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

原创 Leetcode Decode Ways 91

A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2

原创 Leetcode Longest Substring Without Repeating Characters 3

Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”,

原创 Leetcode Reverse Words in a String 151

Given an input string, reverse the string word by word. For example, Given s = “the sky is blue”, return “blue is

原创 Leetcode Binary Watch 401

A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the m