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

什么叫宣传类网站百度对 wordpress 排名

什么叫宣传类网站,百度对 wordpress 排名,广东粤数网络建设有限公司,wordpress 去掉评论问题背景 在一排多米诺骨牌中, t o p s [ i ] tops[i] tops[i] 和 b o t t o m s [ i ] bottoms[i] bottoms[i] 分别代表第 i i i 个多米诺骨牌的上半部分和下半部分。(一个多米诺是两个从 1 1 1 到 6 6 6 的数字同列平铺形成的 —— 该平铺的每一半…

问题背景

在一排多米诺骨牌中, t o p s [ i ] tops[i] tops[i] b o t t o m s [ i ] bottoms[i] bottoms[i] 分别代表第 i i i 个多米诺骨牌的上半部分和下半部分。(一个多米诺是两个从 1 1 1 6 6 6 的数字同列平铺形成的 —— 该平铺的每一半上都有一个数字。)
我们可以旋转第 i i i 张多米诺,使得 t o p s [ i ] tops[i] tops[i] b o t t o m s [ i ] bottoms[i] bottoms[i] 的值交换。
返回能使 t o p s tops tops 中所有值或者 b o t t o m s bottoms bottoms 中所有值都相同的最小旋转次数。
如果无法做到,返回 − 1 -1 1

数据约束

  • 2 ≤ t o p s . l e n g t h ≤ 2 × 1 0 4 2 \le tops.length \le 2 \times 10 ^ 4 2tops.length2×104
  • b o t t o m s . l e n g t h = t o p s . l e n g t h bottoms.length = tops.length bottoms.length=tops.length
  • 1 ≤ t o p s [ i ] , b o t t o m s [ i ] ≤ 6 1 \le tops[i], bottoms[i] \le 6 1tops[i],bottoms[i]6

解题过程

结果要求所有元素都相同,那这意味着如果最后能实现,那么取初始状态的任意一个元素,它或它的翻转状态一定被包含在结果中。
为了方便起见,分别取 t o p [ 0 ] top[0] top[0] b o t t o m [ 0 ] bottom[0] bottom[0] 作为目标,分别计算最小次数,再取其中较小的那个就可以了。

具体实现

class Solution {public int minDominoRotations(int[] tops, int[] bottoms) {int res = Math.min(minRot(tops, bottoms, tops[0]), minRot(tops, bottoms, bottoms[0]));return res == Integer.MAX_VALUE ? -1 : res;}private int minRot(int[] tops, int[] bottoms, int target) {int toTop = 0;int toBottom = 0;for (int i = 0; i < tops.length; i++) {int x = tops[i];int y = bottoms[i];if (x != target && y != target) {return Integer.MAX_VALUE;}if (x != target) {toTop++; } else if (y != target) {toBottom++;}}return Math.min(toTop, toBottom);}
}
http://www.dtcms.com/a/538003.html

相关文章:

  • 网站后台界面设计网站建设系统
  • 天津网站建设推广服务出国用哪个地图app好
  • 中国商标注册网官方网站做彩票网站需要什么收钱的
  • 做网站记者好吗基层网站建设存在困难
  • 建设网站公司地址北京建设网网站
  • 切换C++编译器 报告总结
  • 操作系统5.3.3 减少磁盘延迟时间的方法
  • php小型网站源码山东微道商网络技术有限公司
  • 手机微信网站开发关键词排名优化
  • 做网站之前需要准备什么条件江苏省住房和城乡建设部网站
  • 学习Linux——用户管理
  • 做品牌网站找谁动漫制作
  • php网站中水印怎么做做网站1天转多钱
  • 设计素材网站源码宝安中心医院入职体检多少钱
  • windows系统上安装docker
  • linux ipc之消息队列
  • 英文企业网站开发推广最有效的办法
  • 计算机网络自顶向下方法8——应用层 HTTP报文格式与cookie机制
  • CUDA-GDB(8)——检查程序状态
  • 青海网站建设公明网站建设怎么做
  • 学院网站建设策划书村镇建设年度报表登录网站
  • 西安网站seo技术外贸企业网站模板建设可以吗
  • Rust:函数栈帧 Box智能指针
  • 如何实现大模型 “边生成边显示“
  • 网站排版教程程序员 做网站 微信公众号 赚钱
  • 无人机数据 → 三维模型与光谱指数 → 多源融合特征 → 机器学习模型与机理解释 → 生态应用案例与科研论文
  • 做性的网站有哪些内容科技股有哪些股票龙头2021
  • 深圳网站建设找智恒网络网站做竞价优化
  • 计算机视觉:基于YOLOv8/YOLOv7/YOLOv6/YOLOv5的零售柜商品检测识别系统(Python+PySide6界面+训练代码)(源码+文档)✅
  • 重庆网站设计公司推荐永久免费虚拟主机