码迷,mamicode.com
首页 > 其他好文 > 详细

Careercup\Mitbbs

时间:2015-01-18 11:48:41      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

- G: a vector of strings, find a pair with max of strlen(a) * strlen(b)

  1. O(n*k): get std::bitset() of each string
  2. O(nlgn): sort strings by length
  3. O(n^2): loop from longest. Pruning: record current max strlen(a)*strlen(b), will not check any strlen(c) * strlen(d) < strlen(a) * strlen(b)

  Or: http://www.quora.com/Given-a-dictionary-of-words-how-can-we-efficiently-find-a-pair-words-s-t-they-dont-have-characters-in-common-and-sum-of-their-length-is-maximum

Careercup\Mitbbs

标签:

原文地址:http://www.cnblogs.com/tonix/p/4231574.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!