C++

 class Solution {
public:
/**
* @param dictionary: a vector of strings
* @return: a vector of strings
*/
vector<string> longestWords(vector<string> &dictionary) {
// write your code here
if (dictionary.size() <= ) {
return dictionary;
} vector<string> result;
int max_len = , cur_len; for (int i=; i<dictionary.size(); i++) {
cur_len = dictionary[i].size();
if(cur_len < max_len) {
continue;
}
if(cur_len > max_len) {
result.clear();
max_len = cur_len;
}
result.push_back(dictionary[i]);
}
return result;
}
};

LintCode: Longest Words的更多相关文章

  1. LintCode Longest Common Substring

    原题链接在这里:http://www.lintcode.com/en/problem/longest-common-substring/# 题目: Given two strings, find th ...

  2. LintCode Longest Common Subsequence

    原题链接在这里:http://www.lintcode.com/en/problem/longest-common-subsequence/ 题目: Given two strings, find t ...

  3. [LintCode] Longest Increasing Continuous subsequence

    http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence/# Give you an integer a ...

  4. Lintcode:Longest Common Subsequence 解题报告

    Longest Common Subsequence 原题链接:http://lintcode.com/zh-cn/problem/longest-common-subsequence/ Given ...

  5. Lintcode: Longest Common Substring 解题报告

    Longest Common Substring 原题链接: http://lintcode.com/zh-cn/problem/longest-common-substring/# Given tw ...

  6. [LintCode] Longest Common Prefix 最长共同前缀

    Given k strings, find the longest common prefix (LCP). Have you met this question in a real intervie ...

  7. [LintCode] Longest Increasing Subsequence 最长递增子序列

    Given a sequence of integers, find the longest increasing subsequence (LIS). You code should return ...

  8. [LintCode] Longest Substring Without Repeating Characters

    Given a string, find the length of the longest substring without repeating characters. Have you met ...

  9. [LintCode] Longest Consecutive Sequence 求最长连续序列

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. H ...

  10. [LintCode] Longest Increasing Continuous Subsequence 最长连续递增子序列

    Give an integer array,find the longest increasing continuous subsequence in this array. An increasin ...

随机推荐

  1. 轮子科技的.NET Core分享

    2016年8月11日 应轮子科技一众好友的邀请,在轮子科技给大家做了一个无责任的瞎聊段落,聊聊.NET的Core的一些内容. 恩,演讲者就只有我一个了,讲师是微软的 MVP 杨守斌,就是因为这个,所以 ...

  2. 【java】判断某段字符串的编码方式,并按照新的编码方式输出

    具体操作: String destination ="testå¾·ç\u008E\u009B西äº\u009A"; try { if(destination.equals(n ...

  3. 初学者必读:IBM长文解读人工智能、机器学习和认知计算

    转自:https://zhuanlan.zhihu.com/p/27228015?utm_source=weibo&utm_medium=social 人工智能的发展曾经经历过几次起起伏伏,近 ...

  4. SharePoint JavaScript API 根据文件路径删除文件

    最近,有这么个需求,然后写了几行代码,记录一下.有需要的可以参考一下. 有几个需要注意的地方,就是文件URL要传相对地址,使用网站对象之前要Load一下. 当然,如果你的网站不在根路径下,还可以用oW ...

  5. sys.usb.config webcam

    setprop persist.sys.usb.config webcamecho 0 > /sys/devices/virtual/android_usb/android0/enableech ...

  6. 《Erlang程序设计(第2版)》

    <Erlang程序设计(第2版)> 基本信息 作者: (瑞典)Joe Armstrong 译者: 牛化成 丛书名: 图灵程序设计丛书 出版社:人民邮电出版社 ISBN:9787115354 ...

  7. SVG 使用marker画箭头(一)

    一.使用Marker画箭头 1.定义一个箭头的marker引用 <defs> <marker id='markerArrow' markerWidth='13' markerHeig ...

  8. SVG.js 基础图形绘制整理(二)

    一.折线 var draw = SVG('svg1').size(300, 300); //画折线 //使用字符串点 // var polyline=draw.polyline('0,0 100,50 ...

  9. Svg.Js 简介(转)

    什么是SVG? SVG 指可伸缩矢量图形 (Scalable Vector Graphics) SVG 用来定义用于网络的基于矢量的图形 SVG 使用 XML 格式定义图形 SVG 图像在放大或改变尺 ...

  10. 彻底理解Java的feature模式

    先上一个场景:假如你突然想做饭,但是没有厨具,也没有食材.网上购买厨具比较方便,食材去超市买更放心. 实现分析:在快递员送厨具的期间,我们肯定不会闲着,可以去超市买食材.所以,在主线程里面另起一个子线 ...