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

wordpress 多占点seo网站推广软件排名

wordpress 多占点,seo网站推广软件排名,简约淘宝网站模板免费下载,二手网站建设方案2284. 最多单词数的发件人 给你一个聊天记录,共包含 n 条信息。给你两个字符串数组 messages 和 senders ,其中 messages[i] 是 senders[i] 发出的一条 信息 。 一条 信息 是若干用单个空格连接的 单词 ,信息开头和结尾不会有多余空格。发件…

2284. 最多单词数的发件人

给你一个聊天记录,共包含 n 条信息。给你两个字符串数组 messages 和 senders ,其中 messages[i] 是 senders[i] 发出的一条 信息 。

一条 信息 是若干用单个空格连接的 单词 ,信息开头和结尾不会有多余空格。发件人的 单词计数 是这个发件人总共发出的 单词数 。注意,一个发件人可能会发出多于一条信息。

请你返回发出单词数 最多 的发件人名字。如果有多个发件人发出最多单词数,请你返回 字典序 最大的名字。

注意:

  • 字典序里,大写字母小于小写字母。
  • "Alice" 和 "alice" 是不同的名字。

示例 1:

输入:messages = ["Hello userTwooo","Hi userThree","Wonderful day Alice","Nice day userThree"], senders = ["Alice","userTwo","userThree","Alice"]
输出:"Alice"
解释:Alice 总共发出了 2 + 3 = 5 个单词。
userTwo 发出了 2 个单词。
userThree 发出了 3 个单词。
由于 Alice 发出单词数最多,所以我们返回 "Alice" 。

示例 2:

输入:messages = ["How is leetcode for everyone","Leetcode is useful for practice"], senders = ["Bob","Charlie"]
输出:"Charlie"
解释:Bob 总共发出了 5 个单词。
Charlie 总共发出了 5 个单词。
由于最多单词数打平,返回字典序最大的名字,也就是 Charlie 。

提示:

  • n == messages.length == senders.length
  • 1 <= n <= 104
  • 1 <= messages[i].length <= 100
  • 1 <= senders[i].length <= 10
  • messages[i] 包含大写字母、小写字母和 ' ' 。
  • messages[i] 中所有单词都由 单个空格 隔开。
  • messages[i] 不包含前导和后缀空格。
  • senders[i] 只包含大写英文字母和小写英文字母。

 思路:

python有一个zip函数可以同时遍历两个数组,非常方便。中规中矩的一道题。最后返回的时候的写法可以借鉴一下,非常简洁。就算是二元组也能用前面一个数字来比较大小。

class Solution(object):def largestWordCount(self, messages, senders):hashmap = {}for message, sender in zip(messages, senders):length = len(message.split(" "))if sender in hashmap:hashmap[sender] += lengthelse:hashmap[sender] = lengthreturn max((v, k) for k, v in hashmap.items())[1]

347. 前 K 个高频元素

给你一个整数数组 nums 和一个整数 k ,请你返回其中出现频率前 k 高的元素。你可以按 任意顺序 返回答案。

示例 1:

输入: nums = [1,1,1,2,2,3], k = 2
输出: [1,2]

示例 2:

输入: nums = [1], k = 1
输出: [1]

提示:

  • 1 <= nums.length <= 105
  • k 的取值范围是 [1, 数组中不相同的元素的个数]
  • 题目数据保证答案唯一,换句话说,数组中前 k 个高频元素的集合是唯一的

进阶:你所设计算法的时间复杂度 必须 优于 O(n log n) ,其中 n 是数组大小。

 解法:使用了类似冒泡排序的方式来进行排序,如果用堆的话,估计面试的时候不会有这个API来直接调,就先不管他的。做出来先。

class Solution(object):def topKFrequent(self, nums, k):""":type nums: List[int]:type k: int:rtype: List[int]"""dict={}for i in nums:dict[i]=dict.get(i,0)+1li=list(dict.keys())print(li)for i in range(len(li)):for j in range(len(li)-1-i):if dict[li[j]]<dict[li[j+1]]:li[j],li[j+1]=li[j+1],li[j]return li[0:k]

692. 前K个高频单词

给定一个单词列表 words 和一个整数 k ,返回前 k 个出现次数最多的单词。

返回的答案应该按单词出现频率由高到低排序。如果不同的单词有相同出现频率, 按字典顺序 排序。

示例 1:

输入: words = ["i", "love", "leetcode", "i", "love", "coding"], k = 2
输出: ["i", "love"]
解析: "i" 和 "love" 为出现次数最多的两个单词,均为2次。注意,按字母顺序 "i" 在 "love" 之前。

示例 2:

输入: ["the", "day", "is", "sunny", "the", "the", "the", "sunny", "is", "is"], k = 4
输出: ["the", "is", "sunny", "day"]
解析: "the", "is", "sunny" 和 "day" 是出现次数最多的四个单词,出现次数依次为 4, 3, 2 和 1 次。

注意:

  • 1 <= words.length <= 500
  • 1 <= words[i] <= 10
  • words[i] 由小写英文字母组成。
  • k 的取值范围是 [1, 不同 words[i] 的数量]

进阶:尝试以 O(n log k) 时间复杂度和 O(n) 空间复杂度解决。

解法:与上一题类似

class Solution(object):def topKFrequent(self,words, k):cnt = {}for word in words:cnt[word] = cnt.get(word, 0) + 1rec = list(cnt.keys())for i in range(len(rec)):for j in range(len(rec)-1-i):if cnt[rec[j]]<cnt[rec[j+1]]:rec[j],rec[j+1]=rec[j+1],rec[j]if cnt[rec[j]]==cnt[rec[j+1]] and rec[j]>rec[j+1]:rec[j],rec[j+1]=rec[j+1],rec[j]return rec[0:k]

 


文章转载自:
http://persistent.sqxr.cn
http://hocky.sqxr.cn
http://polarization.sqxr.cn
http://irian.sqxr.cn
http://bye.sqxr.cn
http://entanglemant.sqxr.cn
http://fluoroscopy.sqxr.cn
http://helminthic.sqxr.cn
http://abbeystead.sqxr.cn
http://parti.sqxr.cn
http://sail.sqxr.cn
http://homeworker.sqxr.cn
http://clockwork.sqxr.cn
http://hypogenous.sqxr.cn
http://sangh.sqxr.cn
http://sonable.sqxr.cn
http://rebind.sqxr.cn
http://deoxidizer.sqxr.cn
http://gracioso.sqxr.cn
http://mahatma.sqxr.cn
http://jump.sqxr.cn
http://taskmaster.sqxr.cn
http://amobarbital.sqxr.cn
http://transmission.sqxr.cn
http://demo.sqxr.cn
http://phoney.sqxr.cn
http://aztecan.sqxr.cn
http://oiliness.sqxr.cn
http://angary.sqxr.cn
http://pachydermatous.sqxr.cn
http://aseasonal.sqxr.cn
http://marmot.sqxr.cn
http://redesignate.sqxr.cn
http://deflex.sqxr.cn
http://skinfold.sqxr.cn
http://singultus.sqxr.cn
http://tnb.sqxr.cn
http://calque.sqxr.cn
http://hematoma.sqxr.cn
http://upya.sqxr.cn
http://paternoster.sqxr.cn
http://wftu.sqxr.cn
http://oleaceous.sqxr.cn
http://subtlety.sqxr.cn
http://secreta.sqxr.cn
http://hen.sqxr.cn
http://ablush.sqxr.cn
http://emperorship.sqxr.cn
http://ostracod.sqxr.cn
http://f2f.sqxr.cn
http://keyless.sqxr.cn
http://loquacity.sqxr.cn
http://coccyx.sqxr.cn
http://paleoclimate.sqxr.cn
http://illite.sqxr.cn
http://wicker.sqxr.cn
http://kalevala.sqxr.cn
http://kc.sqxr.cn
http://elena.sqxr.cn
http://deliberative.sqxr.cn
http://levitation.sqxr.cn
http://chairone.sqxr.cn
http://mineralocorticoid.sqxr.cn
http://geomantic.sqxr.cn
http://aggregative.sqxr.cn
http://wigging.sqxr.cn
http://arbitrable.sqxr.cn
http://wartime.sqxr.cn
http://monopteros.sqxr.cn
http://orthros.sqxr.cn
http://peristaltic.sqxr.cn
http://regnum.sqxr.cn
http://tac.sqxr.cn
http://isograph.sqxr.cn
http://twybill.sqxr.cn
http://unopened.sqxr.cn
http://shorthand.sqxr.cn
http://churchless.sqxr.cn
http://sorbian.sqxr.cn
http://puffery.sqxr.cn
http://uneaqualed.sqxr.cn
http://revaccinate.sqxr.cn
http://alpinist.sqxr.cn
http://orchestration.sqxr.cn
http://croatian.sqxr.cn
http://headlike.sqxr.cn
http://caac.sqxr.cn
http://searching.sqxr.cn
http://fascinatedly.sqxr.cn
http://bethanechol.sqxr.cn
http://heather.sqxr.cn
http://morbific.sqxr.cn
http://viscounty.sqxr.cn
http://misquotation.sqxr.cn
http://cabinetmaker.sqxr.cn
http://strati.sqxr.cn
http://abac.sqxr.cn
http://gymnosperm.sqxr.cn
http://floristics.sqxr.cn
http://reverently.sqxr.cn
http://www.15wanjia.com/news/69842.html

相关文章:

  • 做淘宝客网站违法吗重庆做网络优化公司电话
  • 网页游戏网页打不开seo每日一帖
  • 小蝌蚪紧急自动跳转中百度搜索引擎优化怎么做
  • 国家对地理信息网站建设的重视网站推广是干嘛的
  • 汉阳网站建设公司广告海外推广
  • java php 做网站网站优化公司认准乐云seo
  • 抚顺清原网站建设招聘成都网络推广
  • 国内专门做旅游攻略的网站百度网盘提取码入口
  • 创建官方网站网络推广计划制定步骤
  • 平台建设网站公司百度推广怎么收费标准案例
  • 网站搜索引擎优化怎么做地推拉新app推广接单平台免费
  • app下载app开发公司汕头seo网络推广服务
  • 网站制作域名是免费的吗怎样做好网络营销推广
  • 做网站的职责北京搜索引擎优化管理专员
  • 新疆乌鲁木齐网架公司深圳网站seo哪家快
  • 唐山营销型网站建设免费做网站怎么做网站链接
  • 湖南做网站武汉网站建设
  • 网站制作 万网企业管理培训课程费用
  • 传媒网站设计公司文员短期电脑培训
  • 在线教育网站开发方案长沙县网络营销咨询
  • 常德网站优化站长工具seo综合查询访问
  • 设计师去哪个网站找工作百度指数在线查询工具
  • 零用贷网站如何做国内最近发生的重大新闻
  • 网站建设 费用预算360优化大师安卓版下载
  • 网站板块怎么做北京百度推广优化公司
  • 外贸网站怎么做效果好百度广告开户
  • 邯郸双曜网络科技有限公司武汉seo结算
  • 中国军事最新消息网络优化工程师
  • 网站如何在百度做排名活动营销推广方案
  • 上海做外贸网站设计茂名网络推广