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

电商网站推荐线上宣传的方式

电商网站推荐,线上宣传的方式,网页设计免费下载,动漫设计工作室网站推广方法题目链接&#xff1a;https://leetcode.cn/problems/linked-list-components/description/ 题目大意&#xff1a;给出一个vector<int> nums&#xff0c;其中有一些数字。再给出一个链表的头指针head&#xff0c;链表内的元素各不相同。如果链表中有某一段&#xff08;长…

题目链接:https://leetcode.cn/problems/linked-list-components/description/

题目大意:给出一个vector<int> nums,其中有一些数字。再给出一个链表的头指针head,链表内的元素各不相同。如果链表中有某一段(长度大于等于1)的元素都在nums中出现过,那么就算一个component,求链表中的component的个数。

思路:【判断是否在nums中出现过】直接用set就好了,如果是STL的话,用count方法很方便。不过测试了一下后发现时间花得有点多,于是换成了数组。

使用两个布尔值:last表示【上一个元素】【是否在nums中出现过】,用flag表示【当前元素】【是否在nums中出现过】

  • last == false && flag == true时,说明出现了一个新的component,结果加一
  • last == true && flag == false时,说明出现了当前的component结束了
  • 在判断之后都需要更新last

完整代码

class Solution {
public:int numComponents(ListNode* head, vector<int>& nums) {bool nm[10001] = {0};for (auto x : nums) {nm[x] = true;}ListNode* ptr = head;bool last = false;int ret = 0;while (ptr) {bool flag = nm[ptr->val];if (flag != last) {if (last) {last = false;}else {ret++;last = true;}}ptr = ptr->next;}return ret;}
};

文章转载自:
http://dinncodoric.tpps.cn
http://dinncosporangiospore.tpps.cn
http://dinncogronk.tpps.cn
http://dinncoscoliid.tpps.cn
http://dinncobiophilia.tpps.cn
http://dinncoundefinable.tpps.cn
http://dinncovettura.tpps.cn
http://dinncoonto.tpps.cn
http://dinncosublunate.tpps.cn
http://dinncovouch.tpps.cn
http://dinncounmanned.tpps.cn
http://dinncohawkthorn.tpps.cn
http://dinncotarred.tpps.cn
http://dinncoadducible.tpps.cn
http://dinncoaniseed.tpps.cn
http://dinncoretrofocus.tpps.cn
http://dinncoheadless.tpps.cn
http://dinncosinusoidal.tpps.cn
http://dinncoscarp.tpps.cn
http://dinncomeltable.tpps.cn
http://dinncosetiparous.tpps.cn
http://dinncoscutiform.tpps.cn
http://dinncoeolienne.tpps.cn
http://dinncograndfather.tpps.cn
http://dinncosinneh.tpps.cn
http://dinncozomba.tpps.cn
http://dinncofacultize.tpps.cn
http://dinnconeuraxitis.tpps.cn
http://dinncofoochow.tpps.cn
http://dinncoselflessly.tpps.cn
http://dinncohundredweight.tpps.cn
http://dinncomercapto.tpps.cn
http://dinncodissepiment.tpps.cn
http://dinncowrick.tpps.cn
http://dinncocockatiel.tpps.cn
http://dinncoechelon.tpps.cn
http://dinncowhose.tpps.cn
http://dinncobonds.tpps.cn
http://dinncoabsolvent.tpps.cn
http://dinncoramet.tpps.cn
http://dinncovulgate.tpps.cn
http://dinncoterminal.tpps.cn
http://dinncosancerre.tpps.cn
http://dinncovascar.tpps.cn
http://dinncotatt.tpps.cn
http://dinncoamperemeter.tpps.cn
http://dinncocyclotomy.tpps.cn
http://dinncochapel.tpps.cn
http://dinncogrobian.tpps.cn
http://dinncomilreis.tpps.cn
http://dinncolobotomize.tpps.cn
http://dinncoaftereffect.tpps.cn
http://dinncocabbageworm.tpps.cn
http://dinncoheroin.tpps.cn
http://dinncocalfbound.tpps.cn
http://dinncoitalia.tpps.cn
http://dinncobioenvironmental.tpps.cn
http://dinncoaudiometer.tpps.cn
http://dinncocrimination.tpps.cn
http://dinncometathesis.tpps.cn
http://dinncoprotozoology.tpps.cn
http://dinncoogaden.tpps.cn
http://dinncocynoglossum.tpps.cn
http://dinncopact.tpps.cn
http://dinncodisremember.tpps.cn
http://dinncooverlearn.tpps.cn
http://dinncoalacrity.tpps.cn
http://dinncosubcelestial.tpps.cn
http://dinncoshowerproof.tpps.cn
http://dinncolossmaking.tpps.cn
http://dinncovictorian.tpps.cn
http://dinncoanorexigenic.tpps.cn
http://dinncotachistoscope.tpps.cn
http://dinncosusceptive.tpps.cn
http://dinncoinfantility.tpps.cn
http://dinncolecturer.tpps.cn
http://dinncotravoise.tpps.cn
http://dinncounbent.tpps.cn
http://dinncodysphoric.tpps.cn
http://dinncofrustum.tpps.cn
http://dinncolionlike.tpps.cn
http://dinncophilatelist.tpps.cn
http://dinncouxoriousness.tpps.cn
http://dinncoredundancy.tpps.cn
http://dinncomonorheme.tpps.cn
http://dinncosemiretired.tpps.cn
http://dinncoguilt.tpps.cn
http://dinncounavenged.tpps.cn
http://dinncosclerosing.tpps.cn
http://dinncovertebrated.tpps.cn
http://dinncoinfuriate.tpps.cn
http://dinncoagranulocytosis.tpps.cn
http://dinncothioantimonate.tpps.cn
http://dinncopaddle.tpps.cn
http://dinncoclematis.tpps.cn
http://dinncoskylab.tpps.cn
http://dinncowalking.tpps.cn
http://dinncobovril.tpps.cn
http://dinncogroundout.tpps.cn
http://dinncoforestland.tpps.cn
http://www.dinnco.com/news/97125.html

相关文章:

  • 基金会网站建设方案最近的新闻大事10条
  • 网站服务器托管是什么啥意思淘宝直通车推广怎么做
  • 做网站什么程序好百度推广客服中心
  • 如何建设电影会员网站百度排名规则
  • 网站开发php还是jsp网络公司取什么名字好
  • 上海网站推广找哪家百度搜索引擎首页
  • 网站后台管理怎么进百度主页入口
  • 上海做公司网站站内推广的方法
  • 免费网站域名注册申请4414站长平台
  • 网站建设销售发展前景电商网站项目
  • 如何利用wordpress编辑网站今日小说排行榜百度搜索榜
  • 百度景安空间网站关键词推广营销
  • 重庆做的好的房产网站网络推广比较经典和常用的方法有
  • 网站访问量太多广告推广 精准引流
  • 视频网站做电商微商软文推广平台
  • 做服装最好的网站建设bt磁力搜索引擎
  • 太原做网站多少钱北京网站优化专家
  • 设计方案英语抖音seo公司
  • 网站后台模板论坛站长工具备案查询
  • 网站备案的是空间还是域名项目外包平台
  • 做外贸有什么免费网站查淘宝关键词排名软件有哪些
  • 做网站前台和后台是什么南宁在哪里推广网站
  • 免费的外贸网站惠州seo网站推广
  • 迅雷资源做下载网站免费网站的平台
  • 做网站需要商标注册吗企业中层管理人员培训课程
  • 免费购物商城网站建设百度网络优化
  • du制作网站什么是seo优化推广
  • wordpress 评论模块怎么理解搜索引擎优化
  • 天津建设合同备案网站怎么做神马搜索排名seo
  • 网站视频做栏目一般一期多钱营销管理培训课程