public class Solution {
public int MaxProduct(string[] words) {
if (words == null || words.Length == )
{
return ;
}
int len = words.Length;
int[] value = new int[len];
for (int i = ; i < len; i++)
{
string tmp = words[i];
value[i] = ;
for (int j = ; j < tmp.Length; j++)
{
value[i] |= << (tmp[j] - 'a');
}
}
int maxProduct = ;
for (int i = ; i < len; i++)
{
for (int j = i + ; j < len; j++)
{
if ((value[i] & value[j]) == && (words[i].Length * words[j].Length > maxProduct))
{
maxProduct = words[i].Length * words[j].Length;
}
}
}
return maxProduct;
}
}

https://leetcode.com/problems/maximum-product-of-word-lengths/#/description

leetcode318的更多相关文章

  1. [Swift]LeetCode318. 最大单词长度乘积 | Maximum Product of Word Lengths

    Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the tw ...

随机推荐

  1. ARM汇编指令集4

    协处理器cp15操作指令: mcr & mrc •mrc用于读取CP15中的寄存器 •mcr用于写入CP15中的寄存器   什么是协处理器? •SoC内部另一处理核心,协助主CPU实现某些功能 ...

  2. 文字始终均匀分布整个div

    html部分 <div id="div"> <span>这是一段话,这是又一段话!</span> </div> js部分 getFu ...

  3. 模拟form提交数据

    最近在做一个项目,发现ajax不能enctype=”multipart/form-data” 属性的表单,没办法,只能使用form表单直接提交的方法了,但是form表单直接提交会跳转页面,这样很不友好 ...

  4. EditPlus保存时不生成bak文件(转)

    如何设置EditPlus保存时不生成bak文件 EditPlus是一个强大的编辑工具,不单单是编辑文字强大,很多的刚开始学习编程语言的初学者会选择它,例如html,js,php,java.小编刚开始学 ...

  5. ss-libev 源码解析local篇(1): ss_local的启动,客户端连入

    学习研究ss-libev的一点记录(基于版本3.0.6) ss_local主要代码在local.c中,如果作为一个库编译,可通过start_ss_local_server启动local server. ...

  6. B. Clique Problem(贪心)

    题目链接: B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  7. EL表达式可以直接放在url的“ ”里面

    <div class="hc-prm-search search flr"> <form action="/userCenter/projectInfo ...

  8. Fillder手机抓包的使用

    1.Fillder下载地址: http://www.onlinedown.net/soft/73207.htm 2.网络设置 手机和电脑需链接网络相同 3.fillder设置 3.1打开fillder ...

  9. 转载论文关于fir滤波器的fpga实现

    摘 要 本文讨论的FIR滤波器因其具有严格的线性相位特性而得到广泛的应用.在工程实践中,往往要求信号处理具有实时性和灵活性,本论文研究FIR的FPGA解决方案正体现了电子系统的微型化和单片化. 本论文 ...

  10. SMMS 2016 啟用深色主題

    1.用文本類編輯器 打開C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio目錄下的 ssms.pkg ...