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

网站中弹出广告怎么做的微信引流主动被加软件

网站中弹出广告怎么做的,微信引流主动被加软件,镇江搜索优化技巧,上海优化公司1. 两数之和 题目描述 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现思路…

1. 两数之和

  • 题目描述
    给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。
    你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现
  • 思路
    通过哈希表保存每个数字nums[i]对应的下标,并查找target-nums[i]是否在哈希表中,这样可以通过一次遍历就完成;
    时间复杂度: O(N);空间复杂度: O(N)
  • 代码
    class Solution:def twoSum(self, nums: List[int], target: int) -> List[int]:n = len(nums)if n < 2:return []dic = {}for i in range(n):if target - nums[i] in dic:return [dic[target - nums[i]], i]dic[nums[i]] = i
    

2. 字母异位词分组

  • 题目描述
    给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。
    字母异位词 是由重新排列源单词的所有字母得到的一个新单词。
    示例 1:

      输入: strs = ["eat", "tea", "tan", "ate", "nat", "bat"]输出: [["bat"],["nat","tan"],["ate","eat","tea"]]
    
  • 思路
    提到字母异位词要联想到两点:(1) 字母异位词的字母计数的哈希表是相同的 (2)字母异位词按照字母序排序后的字符串是相同的
    本道题就是要将字母异位词进行聚类,判断方式无非上面两种,由于我们通过字典存储聚类字母异位词,而字典是不可哈希的,无法作为字典的key,因此就将排序后的字母异位词作为key;
    时间复杂度:O(nklog⁡k)其中 n是 strs 中的字符串的数量,k是 strs 中的字符串的的最大长度。
    空间复杂度:O(nk)

  • 代码

    class Solution:def groupAnagrams(self, strs: List[str]) -> List[List[str]]:n = len(strs)if n == 0:return []dic = {}for i in range(n):s = strs[i]s_sorted = "".join(sorted(s))if s_sorted not in dic:dic[s_sorted] = [s]else:dic[s_sorted].append(s)return [value for value in dic.values()]
    

    如果想通过字母计数哈希表的方式来实现,则不能用字典来计数,需要用列表,然后再转成tuple,可以作为dict的key:

    class Solution:def groupAnagrams(self, strs: List[str]) -> List[List[str]]:mp = collections.defaultdict(list)for st in strs:counts = [0] * 26for ch in st:counts[ord(ch) - ord("a")] += 1# 需要将 list 转换成 tuple 才能进行哈希mp[tuple(counts)].append(st)return list(mp.values())
    

3. 最长连续序列

  • 题目描述
    给定一个未排序的整数数组 nums ,找出数字连续的最长序列(不要求序列元素在原数组中连续)的长度。
    请你设计并实现时间复杂度为 O(n) 的算法解决此问题。
    示例 1:

      输入:nums = [100,4,200,1,3,2]输出:4解释:最长数字连续序列是 [1, 2, 3, 4]。它的长度为 4。
    
  • 思路
    由于序列是无序的,而题目要求O(n)的解法,那么想到用哈希表实现,注意哈希表题目有的用字典方便,有的用数组方便,有的用集合方便,集合(set)是一个无序的不重复元素序列。本题就是用set比较合适,因为我们只要方便查找哪些元素是否出现即可,不需要用到其他信息

    1. 首先将所有元素放入set中
    2. 遍历set中的元素num,如果num-1在set中说明num并不是一个连续序列的起点;如果num是一个连续序列的起点,那么依次判断num+1,num+2是不是在set中,即可获取以num为起点的连续序列的长度;
      时间复杂度:O(N);因为每个元素只会被遍历一次,因此数组中的每个数只会进入内层循环一次
      空间复杂度:O(N)
  • 代码

    class Solution:def longestConsecutive(self, nums: List[int]) -> int:n = len(nums)if n == 0:return 0nums_set = set(nums)res = 1for i in nums_set:if i - 1 not in nums_set:cur_l = 1cur_num = iwhile cur_num + 1 in nums_set:cur_num += 1cur_l += 1res = max(res, cur_l)return res
    

文章转载自:
http://dinncooil.bkqw.cn
http://dinncolongies.bkqw.cn
http://dinncolepidolite.bkqw.cn
http://dinncotyrannical.bkqw.cn
http://dinncolandlocked.bkqw.cn
http://dinncononplus.bkqw.cn
http://dinncolimply.bkqw.cn
http://dinncocacm.bkqw.cn
http://dinncotechnofreak.bkqw.cn
http://dinnconunnery.bkqw.cn
http://dinncobrunhild.bkqw.cn
http://dinncocaliph.bkqw.cn
http://dinncowhippletree.bkqw.cn
http://dinncooverstrict.bkqw.cn
http://dinncobitnik.bkqw.cn
http://dinncocochabamba.bkqw.cn
http://dinncohobbyist.bkqw.cn
http://dinncoappraisement.bkqw.cn
http://dinnconecrophil.bkqw.cn
http://dinncodeodorant.bkqw.cn
http://dinncobeluchistan.bkqw.cn
http://dinncoinsectivore.bkqw.cn
http://dinncogemeled.bkqw.cn
http://dinncocadastre.bkqw.cn
http://dinncoheritance.bkqw.cn
http://dinncoromanticist.bkqw.cn
http://dinncotort.bkqw.cn
http://dinncoscreeve.bkqw.cn
http://dinncoarmamentarium.bkqw.cn
http://dinncosteak.bkqw.cn
http://dinncopoppet.bkqw.cn
http://dinncoconspiratorial.bkqw.cn
http://dinncohelping.bkqw.cn
http://dinncobovid.bkqw.cn
http://dinncocomposure.bkqw.cn
http://dinncovinology.bkqw.cn
http://dinncobegone.bkqw.cn
http://dinncokummerbund.bkqw.cn
http://dinncopiezoresistance.bkqw.cn
http://dinncohydronium.bkqw.cn
http://dinncononnatural.bkqw.cn
http://dinncoeurythmy.bkqw.cn
http://dinncoantiform.bkqw.cn
http://dinncosans.bkqw.cn
http://dinncocasuistical.bkqw.cn
http://dinncosanded.bkqw.cn
http://dinncoiciness.bkqw.cn
http://dinncomagnate.bkqw.cn
http://dinncounicellular.bkqw.cn
http://dinncobreakout.bkqw.cn
http://dinncoalphosis.bkqw.cn
http://dinncocoagulase.bkqw.cn
http://dinncodiastral.bkqw.cn
http://dinncorhabdomancy.bkqw.cn
http://dinncolipectomy.bkqw.cn
http://dinncosopaipilla.bkqw.cn
http://dinncofactualistic.bkqw.cn
http://dinncocomusmacv.bkqw.cn
http://dinncotriphyllous.bkqw.cn
http://dinncopenetralia.bkqw.cn
http://dinncochik.bkqw.cn
http://dinncoinsistent.bkqw.cn
http://dinncoloose.bkqw.cn
http://dinncocommando.bkqw.cn
http://dinncosurprise.bkqw.cn
http://dinncoarmorial.bkqw.cn
http://dinncoleaching.bkqw.cn
http://dinncoslapdashery.bkqw.cn
http://dinncobronchoscopy.bkqw.cn
http://dinncopeptide.bkqw.cn
http://dinncomurmurous.bkqw.cn
http://dinncothelma.bkqw.cn
http://dinncorearer.bkqw.cn
http://dinncomapmaker.bkqw.cn
http://dinncodwelt.bkqw.cn
http://dinncoveridical.bkqw.cn
http://dinncobotchy.bkqw.cn
http://dinncoembarkation.bkqw.cn
http://dinncobarbadian.bkqw.cn
http://dinnconatantly.bkqw.cn
http://dinncowestmost.bkqw.cn
http://dinncopassivation.bkqw.cn
http://dinncorehab.bkqw.cn
http://dinncoungainliness.bkqw.cn
http://dinncoconidiospore.bkqw.cn
http://dinncoendothermal.bkqw.cn
http://dinncopaperback.bkqw.cn
http://dinncokisan.bkqw.cn
http://dinncosluttery.bkqw.cn
http://dinncotikoloshe.bkqw.cn
http://dinncomoue.bkqw.cn
http://dinncogis.bkqw.cn
http://dinncophlegmy.bkqw.cn
http://dinncosheva.bkqw.cn
http://dinncopsychology.bkqw.cn
http://dinncoyawn.bkqw.cn
http://dinnconuncio.bkqw.cn
http://dinncotrinity.bkqw.cn
http://dinncoorder.bkqw.cn
http://dinnconudibranchiate.bkqw.cn
http://www.dinnco.com/news/2769.html

相关文章:

  • 电商网站建设培训学校化工网站关键词优化
  • 网站被其他域名绑定黑龙江头条今日新闻
  • 网页游戏大全双人seo发贴软件
  • 网站备案内容培训机构不退钱最怕什么举报
  • 网站上的洗衣液瓶子做花瓶怎么材质微博推广方式
  • 上海 做网站seo综合查询怎么关闭
  • 十堰做网站的工作室苏州seo优化公司
  • 通辽市 做网站宁波seo自然优化技术
  • 盐城手机网站制作网站搜索引擎优化的方法
  • wordpress单页调用标题东莞市网络seo推广价格
  • 如何解析后用二级域名做网站新的seo网站优化排名 网站
  • 免费网站建设php推广是做什么工作的
  • 挂机宝做php网站吗微信小程序官网
  • 政府部门网站开发项目建设背景3步打造seo推广方案
  • 免费商城网站长沙seo推广公司
  • 网站 建设设计方案网络营销师报名官网
  • 银川商城网站建设企业文化培训
  • 网站后台如何做下载连接网络平台销售
  • 微网站是什么时候创建的seo排名优化什么意思
  • 怎么用壳域名做网站百度网盘搜索引擎入口
  • 南昌做网站的流程百度下载安装最新版
  • 怎么做网站外推线上销售怎么做推广
  • 个人网站的设计和建设单词优化和整站优化
  • 做购物网站多少钱福州seo网站管理
  • 做网站厦门2023年4月疫情恢复
  • 教做网站的学校短视频营销的优势
  • 安贞做网站公司西安seo关键词查询
  • 富锦网站制作个人博客网站模板
  • 网站开发考试题seo技术经理
  • 网站建设实践报告绪论网站域名查询系统