Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to separate the suspects from others. In t
#coding=gbk import nltk import math def entropy(labels): freqdist = nltk.FreqDist(labels) #Frequency Distributions probs = [freqdist.freq(l) for l in freqdist] #freqdist.freq(l) 是将频率转换成概率.即频率除以总个数等于概率 return -sum([p * math.log(p,2) for p in probs]) p
原题地址:https://oj.leetcode.com/problems/unique-binary-search-trees/ 题意: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ / / / \ \ 3 2 1