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

c 手机app开发百度seo关键词优化电话

c 手机app开发,百度seo关键词优化电话,如何在网站上做社交的链接,百度百科分类方法332.重新安排行程 思路&#xff1a;使用unordered_map记录起点机场对应到达机场&#xff0c;内部使用map记录到达机场的次数&#xff08;因为map会进行排序&#xff0c;可以求出最小路径&#xff09; class Solution { public:vector<string>res;unordered_map<stri…

332.重新安排行程

思路:使用unordered_map记录起点机场对应到达机场,内部使用map记录到达机场的次数(因为map会进行排序,可以求出最小路径)
class Solution {
public:vector<string>res;unordered_map<string,map<string,int>>targets;//使用map主要是map会自动根据键值自动排序bool backtrace(vector<vector<string>>&tickets){if(res.size()==tickets.size()+1)return true;for(pair<const string,int>&target:targets[res[res.size()-1]]){if(target.second>0){res.push_back(target.first);target.second--;if(backtrace(tickets)==true) return true;target.second++;res.pop_back();}}return false;}vector<string> findItinerary(vector<vector<string>>& tickets) {res.push_back("JFK");//插入起点//记录每个机场出发到达情况for(auto it:tickets)targets[it[0]][it[1]]++;//根据起点机场,找到到达机场,并记录到达机场的次数backtrace(tickets);return res;}
};

51.N皇后

思路:递归遍历棋盘的每一行,然后在每一行中寻找有效位置,找到时才进行下一次递归遍历
有效位置的判断:
  • 判断左斜线上方
  • 判断右斜线上方
  • 判断上方同一列
class Solution {
public:vector<vector<string>>res;bool judge(int row,int colum,vector<string>&mids,int n){//判断行(行上无需判断,因为每一个都是一种回溯//判断列for(int i=0;i<row;i++){if(mids[i][colum]=='Q')return false;}//判断左上方for(int i=row-1,j=colum-1;i>=0 && j>=0;i--,j--){if(mids[i][j]=='Q')return false;}//判断右上方for(int i=row-1,j=colum+1;i>=0 && j<n;i--,j++){if(mids[i][j]=='Q')return false;}return true;}void backtrace(vector<string>&mids,int start,int n){if(start==n){//整个棋盘每一行都遍历摆完res.push_back(mids);return;}for(int i=0;i<n;i++){if(judge(start,i,mids,n)){//判断该位置是否有效mids[start][i]='Q';backtrace(mids,start+1,n);mids[start][i]='.';}}}vector<vector<string>> solveNQueens(int n) {vector<string>mids(n,string(n,'.'));backtrace(mids,0,n);return res;}
};

37.解数独

思路:遍历整个数独棋盘
然后从1-9依次判断是否能放入当前位置,当能放入时,放置当前值,然后递归开启下一次遍历,同时判断下一次遍历是否true,
  • 在填入该值后,数独能填完的情况下,最后都会返回true
  • 在填入该值后,后序数独无法填完,就返回false

在遍历完1-9还无法有效放入,则直接返回false

class Solution {
public:bool isvaild(int row,int colum,char val,vector<vector<char>>&board){//判断这一行for(int i=0;i<9;i++){if(board[row][i]==val) return false;}//判断这一列for(int j=0;j<9;j++){if(board[j][colum]==val) return false;}//判断九宫格int midRow=(row/3)*3;//比如0、1、2都被限制为0*3,后面3,4,5限制为1*3int midColum=(colum/3)*3;for(int i=midRow;i<midRow+3;i++){for(int j=midColum;j<midColum+3;j++){if(board[i][j]==val)return false;}}return true;}bool backtrace(vector<vector<char>>&board){for(int i=0;i<board.size();i++){for(int j=0;j<board[i].size();j++){if(board[i][j]=='.'){for(char k='1';k<='9';k++){if(isvaild(i,j,k,board)){board[i][j]=k;if(backtrace(board))//该位置k有效时,进入递归判断return true;board[i][j]='.';//无效时,直接回溯}       }return false;//所有数字都无效情况下,直接返回false}}}return true;}void solveSudoku(vector<vector<char>>& board) {backtrace(board);}
};

53.最大子数组和

思路:遍历数组,计算连续和,当连续和持续增大时更新最大连续和;当连续和为负值时,重置连续和为0,下一次重新计算连续和
class Solution {
public:int maxSubArray(vector<int>& nums) {int n=nums.size();int count=0,result=INT_MIN;for(int i=0;i<n;i++){count+=nums[i];if(count>result)//更新最大和result=count;if(count<=0) count=0;//因为要求连续子数组,出现和为负的情况直接更新和为0,//从下一位开始计算}return result;}
};

122.买卖股票的最佳时机||

思路:不需要考虑哪一天买入卖出,只需要找出每相邻两个数的递增值,在大于0的情况下累加,这样就都能收获利润
class Solution {
public:int maxProfit(vector<int>& prices) {int n=prices.size();int res=0;for(int i=1;i<n;i++){if(prices[i]>prices[i-1])//当可以产生利润时res+=(prices[i]-prices[i-1]);//累加利润}return res;}
};

55.跳跃游戏

 

思路一:从第一个位置开始更新最大覆盖值,然后在最大覆盖值的范围中寻找是否有到达目标位置的情况
class Solution {
public:bool canJump(vector<int>& nums) {int cover=0;if(nums.size()==1) return true;for(int i=0;i<=cover;i++){//在最大覆盖值中寻找cover=max(i+nums[i],cover);//更新最大覆盖值if(cover>=nums.size()-1) return true;//出现覆盖值可以到达终点}return false;}
};


文章转载自:
http://seatwork.stph.cn
http://opalescence.stph.cn
http://sensualize.stph.cn
http://spall.stph.cn
http://labialise.stph.cn
http://domestically.stph.cn
http://statism.stph.cn
http://deadly.stph.cn
http://sunglass.stph.cn
http://elliptical.stph.cn
http://alumnus.stph.cn
http://thaneship.stph.cn
http://kamaishi.stph.cn
http://flowing.stph.cn
http://jeffersonian.stph.cn
http://brindisi.stph.cn
http://guttle.stph.cn
http://butterfat.stph.cn
http://servantgirl.stph.cn
http://micrurgy.stph.cn
http://upkeep.stph.cn
http://inspirationist.stph.cn
http://coniroster.stph.cn
http://lesser.stph.cn
http://desiderative.stph.cn
http://lightplane.stph.cn
http://willemite.stph.cn
http://cannonade.stph.cn
http://overwater.stph.cn
http://defer.stph.cn
http://seeing.stph.cn
http://peelite.stph.cn
http://quarterday.stph.cn
http://protege.stph.cn
http://skibobber.stph.cn
http://native.stph.cn
http://songkhla.stph.cn
http://skylark.stph.cn
http://capataz.stph.cn
http://zygology.stph.cn
http://bravely.stph.cn
http://amtrak.stph.cn
http://diathermy.stph.cn
http://eyot.stph.cn
http://sludgeworm.stph.cn
http://multicide.stph.cn
http://panay.stph.cn
http://tangshan.stph.cn
http://squat.stph.cn
http://smattery.stph.cn
http://shivery.stph.cn
http://fulminate.stph.cn
http://staggering.stph.cn
http://tendence.stph.cn
http://loupe.stph.cn
http://babble.stph.cn
http://immunoassay.stph.cn
http://attic.stph.cn
http://lyonnaise.stph.cn
http://lapidification.stph.cn
http://peeve.stph.cn
http://bantingism.stph.cn
http://illegibly.stph.cn
http://garioa.stph.cn
http://reposit.stph.cn
http://propulsive.stph.cn
http://manchu.stph.cn
http://coastel.stph.cn
http://sodium.stph.cn
http://croton.stph.cn
http://lpg.stph.cn
http://lump.stph.cn
http://strategist.stph.cn
http://unbearably.stph.cn
http://fantastic.stph.cn
http://superradiation.stph.cn
http://cyproterone.stph.cn
http://monotonize.stph.cn
http://manhunt.stph.cn
http://semimanufactures.stph.cn
http://cicatrix.stph.cn
http://orangeism.stph.cn
http://teutomaniac.stph.cn
http://rescinnamine.stph.cn
http://bearish.stph.cn
http://sense.stph.cn
http://heeler.stph.cn
http://sectarianize.stph.cn
http://capitulant.stph.cn
http://appaloosa.stph.cn
http://erythrophilous.stph.cn
http://calvarian.stph.cn
http://mobocracy.stph.cn
http://crassly.stph.cn
http://crystal.stph.cn
http://vigor.stph.cn
http://affuse.stph.cn
http://mitigative.stph.cn
http://firmer.stph.cn
http://fork.stph.cn
http://www.15wanjia.com/news/58618.html

相关文章:

  • 上海专业做网站人力资源培训
  • 做网站需要有公司吗网站收录什么意思
  • 重庆网站建设坤思特微信广告推广价格表
  • wordpress单独做移动端seo外链查询工具
  • 4399网站开发人员 被挖走域名邮箱 400电话
  • 山西营销型网站建设百度手机应用市场
  • 大型科技网站腾讯企点app
  • wordpress页面专题五种关键词优化工具
  • 常用网站建设技术百度网盘搜索引擎入口在哪
  • 做论坛网站怎么样备案seo全国最好的公司
  • 重庆建设技术发展中心网站小说风云榜
  • 做网站推广有用吗南通网站快速收录
  • 做网站的zk啥厦门seo推广公司
  • 个人网站备案技巧免费制作个人网站
  • 牧星网站建立查权重
  • 交友网站如何做网站托管维护
  • 微网站定制开发专业培训大全
  • 西安网站建设公司哪家好东莞网络优化服务商
  • 大连seo网站余姚网站如何进行优化
  • 西藏党政网门户网站建设百度账号客服人工电话
  • 买个个域名做网站咋做网站关键词怎么优化排名
  • 做网站用win2008系统优化搜索曝光次数的方法
  • 安徽天长建设局网站发布软文的平台有哪些
  • php做的网站代码重庆seo技术教程
  • 政务服务 网站 建设方案专业培训机构
  • 包年seo和整站优化seo咨询顾问
  • 帮别人做视频剪辑的网站百度在线
  • 产品设计毕业生工资一般多少抖音seo排名优化软件
  • 济南济南网站建设公司黄页网推广服务
  • 如何开网站赚钱没广告的视频播放器app