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. 转:走近NoSQL数据库的四大家族

    在目前的企业IT架构中,系统管理员以及DBA都会考虑使用NoSQL数据库来解决RDBMS所不能解决的问题,特别是互联网行业.传统的关系型数据库主要以表(table)的形式来存储数据,而无法应对非结构化 ...

  2. jQuery——操作复选框(checkbox) attr checked不起作用

    这天用到jQuery功能,想实现一个简单的复选框动态全选或全不选,结果测试发现 attr(‘checked’,'checked’);与attr(‘checked’,true); 都不好使,要么第一次成 ...

  3. 【51nod-1596】搬货物

    现在有n个货物,第i个货物的重量是 2wi .每次搬的时候要求货物重量的总和是一个2的幂.问最少要搬几次能把所有的货物搬完. 样例解释: 1,1,2作为一组. 3,3作为一组. Input 单组测试数 ...

  4. Django restfull规范

    一. 什么是RESTful REST与技术无关,代表的是一种软件架构风格,REST是Representational State Transfer的简称,中文翻译为“表征状态转移” REST从资源的角 ...

  5. fastjson缺陷--map转换json时出现$ref的情况

    DisableCircularReferenceDetect来禁止循环引用检测: JSON.toJSONString(..., SerializerFeature.DisableCircularRef ...

  6. $fn、$extends $fn.extends的用法,jquery的插件开发

    原文链接:http://caibaojian.com/jquery-extend-and-jquery-fn-extend.html Query.fn.extend(); jQuery.extend( ...

  7. 【MFC】CDC::BitBlt介绍

    CDC::BitBlt介绍 2011-11-04 08:25 19576人阅读 评论(6) 收藏 举报 摘自: http://blog.csdn.net/bberdong/article/detail ...

  8. HDU 3720 Arranging Your Team

    先分组,然后暴力:注意  初始化时不要为0 会有负数:我直接二进制枚举: dfs是正解:呵呵 #include <iostream> #include <cstdio> #in ...

  9. 如何制作CDLinux启动盘

    用笔记本安装虚拟机并且尝试使用CDLinux系统进行无线密码破解的朋友们可能会遇到很多的问题,今天的经验就是总结了很多的失败然后整理出来的,希望能够对大家有所帮助.本次经验来和大家分享一下使用U盘制作 ...

  10. loj #6136. 「2017 山东三轮集训 Day4」Left

    题目: 题解: 我们可以发现所有的交换器都是一个位置连接着下一层左侧的排序网络,另一个位置连着另一侧的排序网络. 而下一层是由两个更低阶的排序网络构成的. 两个网络互不干扰.所以我们可以通过第一行和最 ...