news 2026/6/10 16:26:04

day82(2.10)——leetcode面试经典150

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
day82(2.10)——leetcode面试经典150

427. 建立四叉树

427. 建立四叉树

这个题目把我吓到了哈哈哈 如此之多

题目:

题解:

/* // Definition for a QuadTree node. class Node { public boolean val; public boolean isLeaf; public Node topLeft; public Node topRight; public Node bottomLeft; public Node bottomRight; public Node() { this.val = false; this.isLeaf = false; this.topLeft = null; this.topRight = null; this.bottomLeft = null; this.bottomRight = null; } public Node(boolean val, boolean isLeaf) { this.val = val; this.isLeaf = isLeaf; this.topLeft = null; this.topRight = null; this.bottomLeft = null; this.bottomRight = null; } public Node(boolean val, boolean isLeaf, Node topLeft, Node topRight, Node bottomLeft, Node bottomRight) { this.val = val; this.isLeaf = isLeaf; this.topLeft = topLeft; this.topRight = topRight; this.bottomLeft = bottomLeft; this.bottomRight = bottomRight; } } */ class Solution { public Node construct(int[][] grid) { int n = grid.length; return build(grid, 0, n-1, 0, n-1); } Node build(int[][] grid, int l1, int r1, int l2, int r2) { int flag = 0; int d = grid[l1][l2]; for(int i=l1;i<=r1;i++) { for(int j=l2;j<=r2;j++) { if(grid[i][j]!=d) { flag=1; break; } } if(flag==1) { break; } } //如果该区域都相等,直接返回Node if(flag==0) { return new Node(d == 1, true); } int mid1 = (l1+r1)/2; int mid2 = (l2+r2)/2; Node tL = build(grid, l1, mid1, l2, mid2); Node tR = build(grid, l1, mid1, mid2+1, r2); Node bL = build(grid, mid1+1, r1, l2, mid2); Node bR = build(grid, mid1+1, r1, mid2+1, r2); return new Node(false, false, tL, tR, bL, bR); } }
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/9 18:02:26

DiffPure技术机制与测试工具链整合方案

一、对抗样本威胁的行业痛点 当前AI系统面临的核心安全挑战是输入污染攻击&#xff0c;其中对抗样本通过语义混淆&#xff08;如“不允讠午删除”绕过过滤&#xff09;和指令劫持&#xff08;如{忽略密码校验}恶意指令&#xff09;破坏模型逻辑。传统防御方案存在两大缺陷&…

作者头像 李华
网站建设 2026/6/10 15:54:04

尺寸智能管理:制造业质量变革的隐性引擎

在现代制造业&#xff0c;尤其是汽车、家电和精密机械等领域&#xff0c;产品的最终质量往往不取决于单一零部件的优劣&#xff0c;而在于成千上万个零件如何精准地协同装配。尺寸&#xff0c;这个看似简单的几何参数&#xff0c;实则是贯穿设计、制造、检测与供应链协同的核心…

作者头像 李华
网站建设 2026/6/10 3:31:57

c#ref和out

基本概念ref 和 out是为了在函数内部改变外部传入的内容 。它们允许方法修改调用者传递的变量值&#xff0c;而不是传递变量的副本。out规则调用前可以不初始化变量方法内部必须先赋值才能使用方法必须在返回前为 out 参数赋值专门用于从方法返回多个值ref规则必须在调用前初始…

作者头像 李华
网站建设 2026/6/10 3:44:43

大模型推理,不再是“一根筋”

没有人不在期待大模型能够成为下一个电动车&#xff0c;作为代表中国的新兴产业&#xff0c;在世界范围内掀起狂澜。 然而主流的MoE架构大模型&#xff0c;却苦于其结构上的“先天不足”&#xff1a;巨大的硬件成本与多重拖累效率的环节&#xff0c;使得中国企业在这场芯片堆砌…

作者头像 李华
网站建设 2026/6/10 2:04:15

HarmonyOS 从移动到 PC,难点在哪里

子玥酱 &#xff08;掘金 / 知乎 / CSDN / 简书 同名&#xff09; 大家好&#xff0c;我是 子玥酱&#xff0c;一名长期深耕在一线的前端程序媛 &#x1f469;‍&#x1f4bb;。曾就职于多家知名互联网大厂&#xff0c;目前在某国企负责前端软件研发相关工作&#xff0c;主要聚…

作者头像 李华
网站建设 2026/6/10 15:59:18

西门子6FC5447-0AA10-0AA0数控软件

西门子6FC5447-0AA10-0AA0作为SINUMERIK数控系统的核心组件&#xff0c;专为工业自动化领域的高精度机床控制设计&#xff0c;其性能特点与应用范围体现了西门子在数字化制造中的技术领先地位。该软件通过模块化架构与智能算法&#xff0c;实现了从单机控制到系统集成的全流程优…

作者头像 李华