|
亲!马上注册或者登录会查看更多内容!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
Find the pair of words in a dictionary that don't no same letter and the product of these two words' length is maximum
( k( L+ Z/ ^: l4 {+ b$ B' y4 G9 Y我的idea是,用26位的bitmap表示每个string,把dictionary里的word按照长度排序,从最长的word开始降序来找满足条件的一对words+ M, r8 e: k+ O- [" J
7 X* |. x1 d- Y8 K5 D2 B8 B例如:abc和d分别用0...0111和0...1000表示,接着进行&运算,如果为0,表示两个string没有相同的letter,是我们要找的结果。* S8 h( L, g! ]0 D) @
|
|