当前位置: 首页 > news >正文

北京网站手机站建设公司电话号码开封网络推广哪家好

北京网站手机站建设公司电话号码,开封网络推广哪家好,失物招领网站开发项目需求分析,o2o网站建设效果2019独角兽企业重金招聘Python工程师标准>>> 题目: 给定一段产品的英文描述,包含M个英文单词,每个单词以空格分隔,无其他标点,再给定N个英文单词关键字。请说明思路并编程实现方法 String extractSummary(…

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

题目: 给定一段产品的英文描述,包含M个英文单词,每个单词以空格分隔,无其他标点,再给定N个英文单词关键字。请说明思路并编程实现方法  String extractSummary(String description,String [ ] Keywords):目标是找出此产品描述中包含N个关键词(每个关键词至少出现一次)的长度最短的子串,作为产品简介输出,编程语言不限。

实现方法:在确保所有关键字都包含的情况下,每次从content尾向前挪动一个位置,都从content的头部到尾遍历一遍,碰上小的就付给result,直到完全遍历完

代码:

package test;import java.util.ArrayList;
import java.util.List;/*** @author hy*  2011/6/13*/
public class FindAbstract {static String content[] = { "a", "c", "d", "a", "c", "b", "d", "e", "a","a","b"};static String keyword[] = { "b", "c", "d" };static List<String> contentList = new ArrayList<String>();public static void main(String args[]) {List<String> result = new ArrayList<String>();int begin = 0;int end = content.length;// 将content内容从数组形式变换成List型for (int i = 0; i < end; i++)contentList.add(i, content[i]);// 输出给定的content和keywordSystem.out.print("[content]:  ");for (int i = 0; i < content.length; i++)System.out.print(content[i] + " ");System.out.println();System.out.print("[keyword]:  ");for (int i = 0; i < keyword.length; i++)System.out.print(keyword[i] + " ");System.out.println();// 输出最短摘要result = contentList;System.out.println("[AllMatch]:");for (end = content.length; end - begin >= keyword.length; end--) {for (begin = 0; end - begin >= keyword.length; begin++) {if (isAllHave(contentList.subList(begin, end), keyword)&& result.size() > contentList.subList(begin, end).size()){result = contentList.subList(begin, end);System.out.println("     "+result);}}begin = 0;}System.out.println("[ShortestMatch]: "+result);}// 是否都包含所有关键字static boolean isAllHave(List<String> arr, String key[]) {boolean is = false;int temp = 0;for (int i = 0; i < key.length; i++)if (isKeywordIn(arr, key[i]))temp++;if (temp == key.length)is = true;return is;}// 是否包含单个关键字static boolean isKeywordIn(List<String> arr, String key) {int i;for (i = 0; i < arr.size(); i++)if (arr.get(i) == key)return true;return false;}}

结果:

[content]:  a c d a c b d e a a b
[keyword]:  b c d
[AllMatch]:
     [c, d, a, c, b, d, e, a, a, b]
     [d, a, c, b, d, e, a, a, b]
     [a, c, b, d, e, a, a, b]
     [c, b, d, e, a, a, b]
     [c, b, d, e, a, a]
     [c, b, d, e, a]
     [c, b, d, e]
     [c, b, d]
[ShortestMatch]: [c, b, d]

转载于:https://my.oschina.net/u/147640/blog/23789

http://www.lbrq.cn/news/2516725.html

相关文章:

  • python 做下载网站百度关键词查询工具
  • 网络规划设计师考试内容上海关键词优化报价
  • 青岛网站建设搭建企业网站推广方案设计毕业设计
  • 做网站要注意什么如何优化网站排名
  • portfolio wordpressseo技术培训机构
  • 网站建设常用结构类型教育机构培训
  • 黄石做网站的公司中小企业网络营销现状
  • 中学生做网站友情手机站
  • 如何做双版网站seo关键词排名实用软件
  • 北京电商网站开发费用怎么做免费的网站推广
  • 微信免费做邀请函模版网站怎样制作一个网页
  • 重庆怎么自己做网站看广告收益的正规平台
  • 学网站开发的软件网络营销运营方案
  • 收到网站代码后怎么做重庆森林讲了什么故事
  • 重庆百度网站推广腾讯会议付费
  • 学校网站建设评比专业网站制作网站公司
  • 做网站如何挂支付系统新乡网站seo
  • 长春谁家做网站电商营销的策略与方法
  • 公司简介网站模板怎么创建个人网站
  • wordpress的pdf阅读seo是什么?
  • 在线做章网站搜外友链平台
  • 政府网站 建设依据nba交易最新消息汇总
  • 用jsp做网站登录界面模板潍坊网站关键词推广
  • 怎么找做网站的客户中国的搜索引擎有哪些
  • 上海比较好的服装外贸公司优化网站seo策略
  • 连州住房建设局网站王通seo教程
  • 厦门网站建设公司哪家好seo技术培训沈阳
  • 漳州网站建设回忆互联客服QQ友情链接推广平台
  • 老网站改版做别的上海网络营销seo
  • 网站建设公司优惠大酬宾活动合肥网站建设公司
  • SpringBoot之起步依赖
  • java导出pdf(使用html)
  • 【学习笔记】Lean4 定理证明 ing
  • 电商修图,尺寸修改适配各大电商平台
  • 24点数学游戏(穷举法求解表达式)
  • Java全栈面试实战:从JVM到AI的技术演进之路