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. 自定义音频条形图--p52

    package com.zzw.qunyingzhuan2; import android.content.Context; import android.graphics.Canvas; impor ...

  2. linux简单介绍,helloworld,vi使用,用户管理

    linux特点1.免费的.开源的2.支持多线程.多用户的3.安全性好4.对内存和文件管理优越 缺点:操作相对困难 linux最小只需要4m -> 嵌入式开发 我们使用 vm[虚拟机] 虚拟了一个 ...

  3. jQuery中this与$(this)的区别

    起初以为this和$(this)就是一模子刻出来.但是我在阅读时,和coding时发现,总不是一回事,这里就谈谈this与$(this)的区别. jQuery中this与$(this)的区别 $(&q ...

  4. canvas 绘制环形进度条

    结果: 代码: <!DOCTYPE html> <html> <head lang="en"> <meta charset="U ...

  5. 你必须知道的495个C语言问题,学习体会三

    本文是 本系列的第三篇,本文主要对C语言的表达式做个小结 先从两个坑爹的表达式说起:i++ 与++i 上大学的时候,学长告诉我,这两个表达式,意义是一样的,后来老师纠正说,还是有区别的,于是让我们记住 ...

  6. 记一次诡异的网络故障排除 - tpc_tw_recycle参数引起的网络故障

    一.故障现象 我们团队访问腾讯云上部署的测试环境中的Web系统A时,偶尔会出现类似于网络闪断的情况,浏览器卡很久没有反应,最终报Connection Timeout. 不过奇怪的是,当团队中的某个人无 ...

  7. 《C#求职宝典》读书笔记

    王小科 电子工业出版 第一篇 面试求职第一步 一个例子:一支行军中的队伍长100米,一个传令兵从队尾跑至队头,再立即返回队尾,队伍正好前进了100米.假设队伍 和传令兵行进的速度恒定,问传令兵跑了多少 ...

  8. C# 程序部署、调试时间长的解决办法

    最近在做数控折弯机项目时,VS2008环境下采用C#..NET Compact Framework开发WinCE.Windows Mobile程序时,编译项目非常慢,看着进度条慢慢刷,有时候需要几分钟 ...

  9. Linq:Grouping Operators

    [Category("Grouping Operators")] [Description("This sample uses group by to partition ...

  10. LeetCode Optimal Division

    原题链接在这里:https://leetcode.com/problems/optimal-division/description/ 题目: Given a list of positive int ...