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. Integer类分析(jdk8)

    一.构造函数 1. Integer类继承Number类,实现Comparable接口,重写了compareTo()方法. 2. Integer最小值为-2147483648,最大值为214748364 ...

  2. ADO.NET数据库访问技术(转)

    这几天的自学,现在总结一下关于C#中连接数据库的一些知识点: 1.使用Connection连接数据库的步骤: (1).添加命名空间 System.Data.SqlClient(注意:初学者经常会忘记) ...

  3. pgbench使用记录

    1.初始化: pgbench -i pgbench 如果端口号有变化,需要先手动创建数据库,再执行. pgbench -i -s 10 -p 5433 pgbench 重点:主要用到两个参数,-i:初 ...

  4. Android 进阶7:进程通信之 AIDL 的使用

    读完本文你将了解: AIDL 是什么 AIDL 支持的数据类型 AIDL 如何编写 AIDL 实例 创建 AIDL 编写服务端代码 编写客户端代码 运行结果 总结 代码地址 Thanks 记得 201 ...

  5. MySQL FEDERATED 存储引擎的使用

    FEDERATED 存储引擎描述 FEDERATED存储引擎能让你访问远程的MySQL数据库而不使用replication或cluster技术(类似于Oracle的dblink),使用FEDERATE ...

  6. flask中cookie和session介绍

    flask中cookie和session介绍 一.cookie: 在网站中,http请求是无状态的.也就是说即使第一次和服务器连接后并且登录成功后,第二次请求服务器依然不能知道当前请求是哪个用户.co ...

  7. 洛谷 P2212 [USACO14MAR]浇地Watering the Fields

    传送门 题解:计算欧几里得距离,Krusal加入边权大于等于c的边,统计最后树的边权和. 代码: #include<iostream> #include<cstdio> #in ...

  8. tornado日志管理

    默认数据格式 默认情况下,采用tornado的web框架运行起来之后,任何访问都会直接在控制台输出日志信息,格式如下: [I 160807 09:27:17 web:1971] 200 GET / ( ...

  9. Toolbar使用

    原文地址 http://www.cnblogs.com/Dentist/p/4370176.html Android4.0出现的Actionbar提供了同意方便的导航管理.很大程度的统一了Androi ...

  10. Linux bash shell 入门

    https://www.cnblogs.com/cosiray/archive/2012/03/02/2377099.html