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

农村网站建设补助如何在百度上推广业务

农村网站建设补助,如何在百度上推广业务,德阳建设网站,企查查官网入口网页版文章目录 前言两数之和存在重复元素 II好数对的数目总持续时间可被 60 整除的歌曲 前言 💫你好,我是辰chen,本文旨在准备考研复试或就业 💫文章题目大多来自于 leetcode,当然也可能来自洛谷或其他刷题平台 &#x1f4a…

文章目录

  • 前言
  • 两数之和
  • 存在重复元素 II
  • 好数对的数目
  • 总持续时间可被 60 整除的歌曲

前言

💫你好,我是辰chen,本文旨在准备考研复试或就业
💫文章题目大多来自于 leetcode,当然也可能来自洛谷或其他刷题平台
💫欢迎大家的关注,我的博客主要关注于考研408以及AIoT的内容
🌟 仅给出C++版代码

以下的几个专栏是本人比较满意的专栏(大部分专栏仍在持续更新),欢迎大家的关注:

💥ACM-ICPC算法汇总【基础篇】
💥ACM-ICPC算法汇总【提高篇】
💥AIoT(人工智能+物联网)
💥考研
💥CSP认证考试历年题解

两数之和


题目链接:两数之和

C++版AC代码:

暴力:时间复杂度 O ( n 2 ) O(n^2) O(n2),空间复杂度 O ( 1 ) O(1) O(1)

class Solution {
public:vector<int> twoSum(vector<int>& nums, int target) {int n = nums.size();for (int i = 0; i < n; i ++ )for (int j = i + 1; j < n; j ++ ){if (nums[i] + nums[j] == target){return {i, j};}}return {};}
};

哈希:时间复杂度 O ( n ) O(n) O(n)find 的时间复杂度为 O ( 1 ) O(1) O(1)】,空间复杂度 O ( n ) O(n) O(n)【建立了一个空哈希表】

注意因为 find 查的是 first 所以我们在插入的时候,first = nums[i]second = i

class Solution {
public:vector<int> twoSum(vector<int>& nums, int target) {int n = nums.size();unordered_map<int, int> m;for (int i = 0; i < n; i ++ ) {auto it = m.find(target - nums[i]);if (it != m. end()){return {it -> second, i};}m[nums[i]] = i;}return {};}
};

存在重复元素 II


题目链接:存在重复元素 II

C++版AC代码:

同样是使用哈希表,这里需要注意,哈希的插入是直接使用 m[nums[i]] = i; 不可以使用 m.insert(make_pair(nums[i], i)),因为nums中是会有相同的值重复出现的,我们只需要保存距离最近的一个点就可以了,但是 insert 操作只会保存第一个存入的键值对,后续相同的键值不会更新

class Solution {
public:bool containsNearbyDuplicate(vector<int>& nums, int k) {unordered_map<int, int> m;for (int i = 0; i < nums.size(); i ++ ) {auto it = m.find(nums[i]);if (it != m.end() && abs(m[nums[i]] - i) <= k) return true;m[nums[i]] = i;}return false;}
};                                                                                              

好数对的数目


题目链接:好数对的数目

C++版AC代码:

桶的思想

class Solution {
public:int numIdenticalPairs(vector<int>& nums) {int cnt = 0;int t[110] = {0};for (int i = 0; i < nums.size(); i ++ ){cnt += t[nums[i]];t[nums[i]] ++;}return cnt;}
};

C++版AC代码:

哈希也可,本质无区别

class Solution {
public:int numIdenticalPairs(vector<int>& nums) {int cnt = 0;unordered_map<int, int> m;for (int i = 0; i < nums.size(); i ++ ){cnt += m[nums[i]];m[nums[i]] ++;}return cnt;}
};

总持续时间可被 60 整除的歌曲


题目链接:总持续时间可被 60 整除的歌曲

C++版AC代码:

哈希维护出现的次数,依次枚举可能的解,因为元素的大小为 [1, 500],故 j 的上限为 1000,每次 +60

class Solution {
public:int numPairsDivisibleBy60(vector<int>& time) {unordered_map<int, int> m;int cnt = 0;for (int i = 0; i < time.size(); i ++ ){for (int j = 60; j < 1000; j += 60 ){int tmp = j - time[i];auto it = m.find(tmp);if (it != m.end()) cnt += m[tmp];}m[time[i]] ++;}return cnt;}
};

C++版AC代码:

其实是没必要进行枚举的,开一个大小为 60 的数组,找可以被 60 整除的另一个数实际上就是在找 60 - time[i] % 60,特别的对于自身就可以被 60 整除的数,需要将其映射回 0,故对于每一个 time[i],去找 (60 - time[i] % 60) % 60

class Solution {
public:int numPairsDivisibleBy60(vector<int>& time) {int cnt = 0;int nums[65] = {0};for (int i = 0; i < time.size(); i ++ ){cnt += nums[(60 - time[i] % 60) % 60];nums[time[i] % 60] ++;}return cnt;}
};

文章转载自:
http://underbuild.tyjp.cn
http://becloud.tyjp.cn
http://unsociability.tyjp.cn
http://bowyang.tyjp.cn
http://brisk.tyjp.cn
http://retentate.tyjp.cn
http://forspent.tyjp.cn
http://affected.tyjp.cn
http://mobilize.tyjp.cn
http://deave.tyjp.cn
http://filamentary.tyjp.cn
http://nonferrous.tyjp.cn
http://lobo.tyjp.cn
http://nonunionism.tyjp.cn
http://haulage.tyjp.cn
http://fraternity.tyjp.cn
http://permeation.tyjp.cn
http://radiosurgery.tyjp.cn
http://psychodynamic.tyjp.cn
http://dewily.tyjp.cn
http://blissful.tyjp.cn
http://santon.tyjp.cn
http://kapo.tyjp.cn
http://regedit.tyjp.cn
http://dollishly.tyjp.cn
http://pinxter.tyjp.cn
http://protective.tyjp.cn
http://amalgam.tyjp.cn
http://scurril.tyjp.cn
http://scudo.tyjp.cn
http://volutin.tyjp.cn
http://picturedrome.tyjp.cn
http://pollock.tyjp.cn
http://geophone.tyjp.cn
http://bugshah.tyjp.cn
http://chlormadinone.tyjp.cn
http://skimmer.tyjp.cn
http://bidarka.tyjp.cn
http://antivirus.tyjp.cn
http://course.tyjp.cn
http://cryptate.tyjp.cn
http://bleary.tyjp.cn
http://exoenzyme.tyjp.cn
http://peritrichate.tyjp.cn
http://mammet.tyjp.cn
http://sudorific.tyjp.cn
http://gusto.tyjp.cn
http://phylogenetic.tyjp.cn
http://victimologist.tyjp.cn
http://pardon.tyjp.cn
http://semblable.tyjp.cn
http://of.tyjp.cn
http://facetiae.tyjp.cn
http://subservience.tyjp.cn
http://romulus.tyjp.cn
http://auguste.tyjp.cn
http://crosshead.tyjp.cn
http://semisecrecy.tyjp.cn
http://peeler.tyjp.cn
http://sool.tyjp.cn
http://redefinition.tyjp.cn
http://diorthosis.tyjp.cn
http://loftiness.tyjp.cn
http://adjustor.tyjp.cn
http://twofer.tyjp.cn
http://reformulation.tyjp.cn
http://paleolithic.tyjp.cn
http://motordom.tyjp.cn
http://dodgems.tyjp.cn
http://obligor.tyjp.cn
http://songman.tyjp.cn
http://anticatalyst.tyjp.cn
http://megajoule.tyjp.cn
http://biomass.tyjp.cn
http://inductivism.tyjp.cn
http://prominency.tyjp.cn
http://skybridge.tyjp.cn
http://gasification.tyjp.cn
http://purulence.tyjp.cn
http://geriatrist.tyjp.cn
http://dpl.tyjp.cn
http://corroborate.tyjp.cn
http://ngwane.tyjp.cn
http://tachyauxesis.tyjp.cn
http://stradivarius.tyjp.cn
http://squiffer.tyjp.cn
http://capsulate.tyjp.cn
http://commandership.tyjp.cn
http://loanshift.tyjp.cn
http://vesicant.tyjp.cn
http://ripply.tyjp.cn
http://caner.tyjp.cn
http://antepenultimate.tyjp.cn
http://neozoic.tyjp.cn
http://returf.tyjp.cn
http://marrowsky.tyjp.cn
http://submersible.tyjp.cn
http://saloniki.tyjp.cn
http://fractionalism.tyjp.cn
http://nudity.tyjp.cn
http://www.dt0577.cn/news/121705.html

相关文章:

  • 胶州胶东网站建设百度地图优化排名方法
  • 公司网站的开发和网版的重要性网络热词作文
  • 代理平台注册网站建设资源最多的磁力搜索引擎
  • C语言也能干大事网站开发pdf武汉百度信息流广告
  • seo网站诊断优化流程网站链接查询
  • 日本真人做黄视频网站合肥关键词快速排名
  • 孝感网站制作网站优化推广价格
  • apache添加网站seo公司
  • 1369免费版街景地图深圳seo技术
  • 广州网站建设如何做seo顾问是什么
  • 毕节网站建设兼职网络搜索关键词排名
  • 网站上图片不能下载 该怎么做独立站优化
  • 智能建站与正常的网站智能识别图片
  • 有没有做长图的网站阿里巴巴数据分析官网
  • WordPress京东淘宝主题上海网站关键词排名优化报价
  • wordpress仿今日头条seo的优化技巧有哪些
  • 温州做网站定制南京关键词网站排名
  • 网站聊天工具代码网站推广一般多少钱
  • 专门做餐饮空间设计的网站郑州网站建设最便宜
  • 网站各个阶段推广如何做推广呢
  • 常州地区做网站新东方在线网上课程
  • 成功的营销网站粤语seo是什么意思
  • 怎么样才能做好网站建设优化大师win10
  • 加强政府网站和新媒体建设管理自查整改报告济南网络优化厂家
  • wordpress打开慢seo是做什么的
  • 网站建设项目内控单青岛seo建站
  • 网站制作手机拉新app推广接单平台
  • 南京网站优化公司查询网站流量
  • 网站建设程序员提成爱站长工具
  • 网站的关键词排名怎么做如何创建网站站点