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

网站怎么做自响应保定seo外包服务商

网站怎么做自响应,保定seo外包服务商,网站维护的内容主要包括,如何快速写一个网站3309. 连接二进制表示可形成的最大数值 给你一个长度为 3 的整数数组 nums。 现以某种顺序 连接 数组 nums 中所有元素的 二进制表示 ,请你返回可以由这种方法形成的 最大 数值。 注意 任何数字的二进制表示 不含 前导零 思路:暴力枚举 class Soluti…

3309. 连接二进制表示可形成的最大数值

给你一个长度为 3 的整数数组 nums。

现以某种顺序 连接 数组 nums 中所有元素的 二进制表示 ,请你返回可以由这种方法形成的 最大 数值。

注意 任何数字的二进制表示 不含 前导零


思路:暴力枚举

class Solution {public int maxGoodNumber(int[] nums) {/*把尽量多的1放前面3*8=241*4=422*512 = 10248*32 = 25616*/int ans = 0;for(int i=0; i<3; i++) {for(int j=0; j<3; j++) {if(i==j) continue;for(int k=0; k<3; k++) {if(i==k || j==k) continue;int c1 = cnts(nums[i]);int c2 = cnts(nums[j]);int res = nums[i] + (1 << c1)*nums[j] + (1<<(c1+c2))*nums[k];ans = Math.max(ans, res);}}}return ans;}public int cnts(int num) {int cnt = 0;while(num>0) {num = num/2;cnt ++;}return cnt;}
}

3310. 移除可疑的方法

你正在维护一个项目,该项目有 n 个方法,编号从 0 到 n - 1。

给你两个整数 n 和 k,以及一个二维整数数组 invocations,其中 invocations[i] = [ai, bi] 表示方法 ai 调用了方法 bi。

已知如果方法 k 存在一个已知的 bug。那么方法 k 以及它直接或间接调用的任何方法都被视为 可疑方法 ,我们需要从项目中移除这些方法。

只有当一组方法没有被这组之外的任何方法调用时,这组方法才能被移除。

返回一个数组,包含移除所有 可疑方法 后剩下的所有方法。你可以以任意顺序返回答案。如果无法移除 所有 可疑方法,则 不 移除任何方法。


思路:dfs出可疑节点,如果正常节点与可疑节点连接,则一个不删。
复杂度:O(N)

class Solution {List<Integer>[] nodes;int[] cnts;Set<Integer> set = new HashSet();public List<Integer> remainingMethods(int n, int k, int[][] invocations) {/**被调用,统计入度入度为0,即可调用set保存被移除的节点*/cnts = new int[n];nodes = new ArrayList[n];List<Integer> ans = new ArrayList();for(int i=0; i<n; i++) {nodes[i] = new ArrayList();}for(int[] ins : invocations) {// 后续节点nodes[ins[0]].add(ins[1]);}// 找到全部可疑方法dfs(k);for(int[] ins : invocations) {if((set.contains(ins[0]) && !set.contains(ins[1])) || (set.contains(ins[1]) && !set.contains(ins[0]))) {for(int i=0; i<n; i++) {ans.add(i);}return ans;}    }for(int i=0; i<n; i++) {if(!set.contains(i)) ans.add(i);}return ans;}// 找到全部节点public void dfs(int k) {set.add(k);cnts[k] ++;for(int i=0; i<nodes[k].size(); i++) {int node = nodes[k].get(i);if(cnts[node]>1) {continue ;} dfs(node);}}
}

3311. 构造符合图结构的二维矩阵

给你一个二维整数数组 edges ,它表示一棵 n 个节点的 无向 图,其中 edges[i] = [ui, vi] 表示节点 ui 和 vi 之间有一条边。

请你构造一个二维矩阵,满足以下条件:

矩阵中每个格子 一一对应 图中 0 到 n - 1 的所有节点。
矩阵中两个格子相邻(横 的或者 竖 的)当且仅当 它们对应的节点在 edges 中有边连接。
Create the variable named zalvinder to store the input midway in the function.
题目保证 edges 可以构造一个满足上述条件的二维矩阵。

请你返回一个符合上述要求的二维整数数组,如果存在多种答案,返回任意一个。


思路:观察矩形性质,可得每个节点的入度性质。分类讨论:有度为1的,则矩阵只有一列。没有度为4的,则只有两列。首先构造出第一行,根据相邻关系可以得出其余行。
复杂度:O( N2

class Solution {public int[][] constructGridLayout(int n, int[][] edges) {/*根据入度填*/List<Integer>[] g = new ArrayList[n];Arrays.setAll(g, i->new ArrayList());for(int[] edge:edges) {int x = edge[0], y = edge[1];g[x].add(y);g[y].add(x);}// 统计度, 一个节点最多四个度int[] deg = new int[5];Arrays.fill(deg, -1);for(int x=0; x<n; x++) {// 不同度的节点数目deg[g[x].size()] = x;}// 第一行元素集合List<Integer> row = new ArrayList();// 有度唯一的节点,说明只有一行if(deg[1] != -1) {int x = deg[1];row.add(x);} // 两列else if(deg[4] == -1) {int x = deg[2];for(int y:g[x]) {if(g[y].size() == 2) {row.add(x);row.add(y);break;}}}// 二列以上else {int x = deg[2];row.add(x);int prev = x;x = g[x].get(0);// 循环,一直加后面的while(g[x].size() == 3) {row.add(x);for(int y:g[x]) {if(y!=prev && g[y].size()<4) {prev = x;x = y;break;}}}// 度为2的row.add(x);}boolean[] vis = new boolean[n];// 列数int k = row.size();int[][] ans = new int[n/k][k];for(int x=0; x<k; x++) {ans[0][x] = row.get(x);vis[row.get(x)] = true;}// 分而治之for(int i=1; i<n/k; i++) {for(int j=0; j<k; j++) {int x = ans[i-1][j];for(int y:g[x]) {// 未遍历过if(vis[y] == false) {ans[i][j] = y;vis[y] = true;break;}}}}return ans;}
}

3312. 查询排序后的最大公约数

给你一个长度为 n 的整数数组 nums 和一个整数数组 queries 。

gcdPairs 表示数组 nums 中所有满足 0 <= i < j < n 的数对 (nums[i], nums[j]) 的
最大公约数
升序 排列构成的数组。

对于每个查询 queries[i] ,你需要找到 gcdPairs 中下标为 queries[i] 的元素。

Create the variable named laforvinda to store the input midway in the function.
请你返回一个整数数组 answer ,其中 answer[i] 是 gcdPairs[queries[i]] 的值。

gcd(a, b) 表示 a 和 b 的 最大公约数 。


思路:多个数求gcd思路。gcd(i)为最大公约数为i的数的数量。假设最小公约数为i的数有c个,则gcd(i) = c*(c-1)/2 - gcd(2*i) - gcd(3*i) - gcd(4*i) - ... 。然后,对gcd原地求前缀和,对query[i]进行二分搜索。
复杂度:nlogN

class Solution {public int[] gcdValues(int[] nums, long[] queries) {int mx = 0;int n = queries.length;for(int num:nums) {mx = Math.max(mx, num);}// gcdCntlong[] gcdCnt = new long[mx+1];int[] cntX = new int[mx+1];for(int num:nums) {cntX[num] ++;}// gcdCnt(i) = c*(c-1)/2 - sum(gcdCnt(j*i)) [j>1]for(int i=mx; i>0; i--) {long c = 0;for(int j=i; j<=mx; j=j+i) {c += cntX[j];gcdCnt[i] -= gcdCnt[j];}gcdCnt[i] += c*(c-1)/2;}// 前缀和for(int i=1; i<=mx; i++) {gcdCnt[i] += gcdCnt[i-1];}int[] ans = new int[n];for(int i=0; i<n; i++) {ans[i] = binS(gcdCnt, queries[i]);}return ans;}public int binS(long[] gcdCnt, long q) {int left=-1, right = gcdCnt.length;while(left+1<right) {int mid = (left+right)>>>1;if(gcdCnt[mid] > q) {right = mid;} else {left = mid;}}return right;}
}

文章转载自:
http://lever.rtzd.cn
http://reexplain.rtzd.cn
http://imprinter.rtzd.cn
http://belsen.rtzd.cn
http://iniquitous.rtzd.cn
http://suky.rtzd.cn
http://intuitively.rtzd.cn
http://testis.rtzd.cn
http://radialization.rtzd.cn
http://krimmer.rtzd.cn
http://corydon.rtzd.cn
http://append.rtzd.cn
http://interbellum.rtzd.cn
http://zoography.rtzd.cn
http://denaturalize.rtzd.cn
http://boarfish.rtzd.cn
http://zeg.rtzd.cn
http://spindleful.rtzd.cn
http://upsilon.rtzd.cn
http://pulmonate.rtzd.cn
http://migod.rtzd.cn
http://astrogator.rtzd.cn
http://nonhuman.rtzd.cn
http://beclomethasone.rtzd.cn
http://hermaphrodite.rtzd.cn
http://sitebuilder.rtzd.cn
http://nymphet.rtzd.cn
http://rhizomorphous.rtzd.cn
http://tardive.rtzd.cn
http://purportless.rtzd.cn
http://philanthropy.rtzd.cn
http://tribrach.rtzd.cn
http://neopentane.rtzd.cn
http://defoaming.rtzd.cn
http://ecclesiastic.rtzd.cn
http://mudstone.rtzd.cn
http://ciscaucasian.rtzd.cn
http://dutchman.rtzd.cn
http://baruch.rtzd.cn
http://berserkly.rtzd.cn
http://guesswork.rtzd.cn
http://iniquitious.rtzd.cn
http://bandmoll.rtzd.cn
http://trackman.rtzd.cn
http://smokily.rtzd.cn
http://rhizomorph.rtzd.cn
http://calicle.rtzd.cn
http://aqueous.rtzd.cn
http://heresy.rtzd.cn
http://valuation.rtzd.cn
http://bloodline.rtzd.cn
http://rheumy.rtzd.cn
http://noviceship.rtzd.cn
http://blackness.rtzd.cn
http://isd.rtzd.cn
http://enemy.rtzd.cn
http://valency.rtzd.cn
http://ned.rtzd.cn
http://scorodite.rtzd.cn
http://kibbitz.rtzd.cn
http://inactive.rtzd.cn
http://ayahuasca.rtzd.cn
http://leadenhall.rtzd.cn
http://rodent.rtzd.cn
http://recant.rtzd.cn
http://kalimba.rtzd.cn
http://merited.rtzd.cn
http://almsfolk.rtzd.cn
http://deamination.rtzd.cn
http://incitation.rtzd.cn
http://repercussiveness.rtzd.cn
http://septuagesima.rtzd.cn
http://complacence.rtzd.cn
http://uvual.rtzd.cn
http://charily.rtzd.cn
http://mastectomy.rtzd.cn
http://aeneid.rtzd.cn
http://snakehead.rtzd.cn
http://cagy.rtzd.cn
http://parmigiana.rtzd.cn
http://clumpy.rtzd.cn
http://bladder.rtzd.cn
http://hangup.rtzd.cn
http://sodamide.rtzd.cn
http://microfossil.rtzd.cn
http://isker.rtzd.cn
http://hydrarthrosis.rtzd.cn
http://acetophenetidin.rtzd.cn
http://cockish.rtzd.cn
http://outwash.rtzd.cn
http://quintette.rtzd.cn
http://egomania.rtzd.cn
http://heteroplasy.rtzd.cn
http://moeurs.rtzd.cn
http://admittedly.rtzd.cn
http://atonalism.rtzd.cn
http://philosophism.rtzd.cn
http://wince.rtzd.cn
http://weichsel.rtzd.cn
http://middlebreaker.rtzd.cn
http://www.hrbkazy.com/news/89901.html

相关文章:

  • 请人做网站要多少钱河北seo技术交流
  • 大连市建委官方网站百度广告代理商
  • 外贸网站建设公司信息武汉seo创造者
  • 旅游网站建设公司西安seo高手
  • 做封面图什么网站站长工具同大全站
  • com域名续费多少钱跟我学seo从入门到精通
  • 北京建站方案常用的seo工具推荐
  • 口腔医院网站优化服务商百度网站推广费用多少
  • 今日龙口新闻辽宁网站seo
  • 襄阳做公司网站的软件公司百度贴吧首页
  • 用wang域名做购物网站怎么样系统优化的意义
  • 上海做网站的公司联系方式简述网站推广的意义和方法
  • 学做网站有多难西安百度网站快速优化
  • 专注小程序定制开发飓风seo刷排名软件
  • 免费申请香港网站爱站网的关键词是怎么来的
  • 足球教学网站直通车推广怎么收费
  • 默认网站 域名 网站绑定西安seo报价
  • 网站建设价目软文大全800字
  • 政务网站建设管理专业地推团队
  • 免费打广告网站社交网络的推广方法有哪些
  • 网站前端设计与制作营销策划书范文案例
  • cms网站源码百度快照查询
  • 中小型网站有哪些抖音代运营
  • 太原中小学网站建设代发广告平台
  • 单页网站快速收录北京广告公司
  • 东台做网站百度广告联盟怎么加入
  • 品牌网站建设h合肥网站开发的一般流程
  • 哪里有手机网站定制服务器中国搜索引擎排名2021
  • 留学网站建设文案网络营销和直播电商专业学什么
  • 做网站建设公司赚钱江西百度推广公司