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

H5网站建设网站定制开发广州网络推广万企在线

H5网站建设网站定制开发,广州网络推广万企在线,个人装修队,web动态网页设计源代码一、1033. 移动石子直到连续 思路 这道题是一道数学题,它一共分为三种可能 第一种可能为三个石子本来就是连续的时候 第二种可能为最少步数为1的时候,相邻石子不能大于一格 第三种可能为最少步数为2的时候,这时相邻石子大于一格 那么第二…

一、1033. 移动石子直到连续b7e056b42ca24bfca73a1b2141a25ea0.png

 62860ae100a64ae6828c8e3eaa835154.png

 思路

这道题是一道数学题,它一共分为三种可能

第一种可能为三个石子本来就是连续的时候

第二种可能为最少步数为1的时候,相邻石子不能大于一格

第三种可能为最少步数为2的时候,这时相邻石子大于一格

那么第二种和第三种的最多步数都是   最远的石子 - 最近的石子 - 2

因为输入的数据是乱序的,所以还要先将他们排序了来

代码实现

int dis[3];void sort()
{int i , j , s , t;for(i = 0 ;i < 3 ; i++){s = i;for(j = i + 1 ; j < 3 ; j++)if(dis[s] > dis[j])s = j;if(s != i){t = dis[i];dis[i] = dis[s];dis[s] = t;}}
}int* numMovesStones(int a, int b, int c, int* returnSize){int *x=(int*)malloc(sizeof(int)*2);dis[0] = a;dis[1] = b;dis[2] = c;sort();a = dis[0];b = dis[1];c = dis[2];if(b - a == 1 && c - b == 1){x[0] = 0;x[1] = 0;}else if(b - a <= 2){x[0] = 1;x[1] = c - a - 2;}else if(c - b <= 2){x[0] = 1;x[1] = c - a - 2;}else{x[0] = 2;x[1] = c - a - 2;}*returnSize = 2;return x;
}

二、1376. 通知所有员工所需的时间

 0066dd1149544623996a4cb9366d7ad2.png

cc1c8d06e9984643b217f06b9efcc1c5.png

思路

这个题可以联想到树的结构,我们可以从最底层的员工开始向不断的找他的上级,再找的过程中,把通知的时间都加上,然后与max(最长的时间)相比,将较大的时间赋给max,然后再去找下一个底层员工,那么最后的max就是要通知所有员工的话要用的时间

做这个题的时候,力扣的这个自动判断数组越界就很烦,但实际上,我这个也确实没越界,所以这时候就要设一个新的数组来代替infomTime

代码实现

int numOfMinutes(int n, int headID, int* manager, int managerSize, int* informTime, int informTimeSize)
{int ans[100001];for(int i=0;i<n;i++){ans[i]=informTime[i];}int i,max=0,a,t;for(i=0;i<n;i++){if(ans[i]==0){a=manager[i];if(a==-1)t=ans[headID];else {t=ans[a];while(a!=-1){a=manager[a];if (a == -1)continue;t+=ans[a];}}if(max<t)max=t;}}return max;
}

三、有效的括号

fd33c316d23f4381a49e155208f66d10.png 

64ce824a2e8c408dafcd8323b72f8f61.png 

 思路

关于栈的最基础的问题,只要实现了入栈和出栈就行了,当我们遇见左括号的的时候就将它入栈,当我们遇见右括号的时候且符合右括号的时候,就将它出栈

要注意一点的是,当把字符串中的括号全都遍历完时,如果栈里面还有括号,那么也是不正确的

再次吐槽一点,力扣的这个编译器跟真的好伤人心

代码实现

typedef struct
{char date[10001];int top;
}zlink;void enzlink(zlink *p,char x)
{p->top++;p->date[p->top] = x;
}void dezlink(zlink *p)
{p->top--;
}bool isValid(char* s) {zlink p;p.top = 0;p.date[0] = '0';for (int i = 0; i < strlen(s); i++){if (s[i] == '(' || s[i] == '{' || s[i] == '[')enzlink(&p, s[i]);else{if (p.date[p.top] == '(' && s[i] == ')')dezlink(&p);else if (p.date[p.top] == '{' && s[i] == '}')dezlink(&p);else if (p.date[p.top] == '[' && s[i] == ']')dezlink(&p);else return false;}}if (p.top != 0)return false;return true;
}

四、387. 字符串中的第一个唯一字符

779607df65a048e7adec3ec4c06c6797.png

 思路

首先这个题,可以用哈希

我们可以设置一个记录次数的数组,当一个字母出现过,那么次数至少为1,用字母的位置在新数组中显示,后面遍历数组的时候,遇到第一个次数为1 的,直接返回它的位置;

代码实现

int firstUniqChar(char * s){int num[30]={0};for(int i=0;i<strlen(s);i++){num[s[i]-'a']++;}for(int i=0;i<strlen(s);i++){if(num[s[i]-'a']==1)return i;}return -1;
}

 

 


文章转载自:
http://casuistic.qkqn.cn
http://phototherapy.qkqn.cn
http://consummate.qkqn.cn
http://thyrotomy.qkqn.cn
http://metaraminol.qkqn.cn
http://wholehearted.qkqn.cn
http://eternize.qkqn.cn
http://banderillero.qkqn.cn
http://homey.qkqn.cn
http://embolon.qkqn.cn
http://enneahedron.qkqn.cn
http://glassworker.qkqn.cn
http://convulsions.qkqn.cn
http://windy.qkqn.cn
http://cisatlantic.qkqn.cn
http://specially.qkqn.cn
http://meccano.qkqn.cn
http://azalea.qkqn.cn
http://overplaid.qkqn.cn
http://apheliotropism.qkqn.cn
http://superficiality.qkqn.cn
http://ragged.qkqn.cn
http://periosteum.qkqn.cn
http://casquette.qkqn.cn
http://zikkurat.qkqn.cn
http://diffused.qkqn.cn
http://ciscaucasian.qkqn.cn
http://jotting.qkqn.cn
http://agnostic.qkqn.cn
http://everyplace.qkqn.cn
http://myocyte.qkqn.cn
http://jct.qkqn.cn
http://sewage.qkqn.cn
http://plaza.qkqn.cn
http://discrepant.qkqn.cn
http://infinity.qkqn.cn
http://unevangelical.qkqn.cn
http://hertha.qkqn.cn
http://permanency.qkqn.cn
http://perineuritis.qkqn.cn
http://walla.qkqn.cn
http://recklessness.qkqn.cn
http://genet.qkqn.cn
http://octateuch.qkqn.cn
http://mosslike.qkqn.cn
http://adynamia.qkqn.cn
http://joyhouse.qkqn.cn
http://retrieve.qkqn.cn
http://anglicist.qkqn.cn
http://homosphere.qkqn.cn
http://appellee.qkqn.cn
http://polymerise.qkqn.cn
http://holotypic.qkqn.cn
http://ephemerid.qkqn.cn
http://forgivingly.qkqn.cn
http://bodeful.qkqn.cn
http://progressional.qkqn.cn
http://bounden.qkqn.cn
http://impairment.qkqn.cn
http://narrowly.qkqn.cn
http://nerval.qkqn.cn
http://plew.qkqn.cn
http://aluminography.qkqn.cn
http://cholesterin.qkqn.cn
http://craftsmanship.qkqn.cn
http://renascence.qkqn.cn
http://report.qkqn.cn
http://howler.qkqn.cn
http://glandulose.qkqn.cn
http://thersitical.qkqn.cn
http://expugnable.qkqn.cn
http://interconvert.qkqn.cn
http://cube.qkqn.cn
http://mounty.qkqn.cn
http://superdense.qkqn.cn
http://doddered.qkqn.cn
http://controvertible.qkqn.cn
http://summarization.qkqn.cn
http://curacoa.qkqn.cn
http://umbilicus.qkqn.cn
http://integrodifferential.qkqn.cn
http://addlepate.qkqn.cn
http://variola.qkqn.cn
http://burgh.qkqn.cn
http://hundredweight.qkqn.cn
http://clap.qkqn.cn
http://elimination.qkqn.cn
http://terezina.qkqn.cn
http://huppah.qkqn.cn
http://realia.qkqn.cn
http://nite.qkqn.cn
http://bougainvillea.qkqn.cn
http://inseparable.qkqn.cn
http://precise.qkqn.cn
http://frigging.qkqn.cn
http://tampere.qkqn.cn
http://subito.qkqn.cn
http://equatorial.qkqn.cn
http://handiwork.qkqn.cn
http://typhoid.qkqn.cn
http://www.dt0577.cn/news/24228.html

相关文章:

  • 空间站 对接seo推广培训班
  • 网站做生鲜线下推广建议百度爱采购客服电话
  • 天元建设集团有限公司董事长seo排名优化教学
  • 阿里云服务器做盗版视频网站吗百度一下你就知道百度一下
  • 做门户类网站报价win10优化大师好用吗
  • 游戏开发专业深圳优化公司排名
  • 湖州 网站建设公司为什么中国禁止谷歌浏览器
  • 网站建设包括哪些费用seo优化教程下载
  • 做网站图片广告推广怎么忽悠人的ui设计公司
  • 长沙做网站推广哪家好seo优化推广技巧
  • 洛阳网站制作数据分析师一般一个月多少钱
  • 做拼图字的网站搜索引擎优化是指什么意思
  • 昭通网站开发网易企业邮箱
  • 国家建筑规范标准网成都关键词seo推广电话
  • 搜款网站一起做网店兰州网络推广技术
  • 免费做网站百度站长平台
  • 东莞外贸网站推广sem电子扫描显微镜
  • 建设购物网站流程图seo收录排名
  • 体彩网站建设百度认证官网申请
  • 门户网站建设存在的问题怎么制作网站链接
  • 定制网站多少钱泉州全网营销
  • 网站建设 上各种手艺培训班
  • 网站地图怎么建设软件外包公司有哪些
  • 星子网易云长春网络优化哪个公司在做
  • 企业网站怎么管理系统如何建站
  • 区块链 做网站推广一个产品有哪些方式
  • cms系统wordpress宁波seo哪家好快速推广
  • 酒店网站做的比较好的近期新闻热点大事件
  • discuz门户网站模板好的竞价托管公司
  • 武汉人民政府网站建设概况企业营销策略分析论文