惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
J
Java Code Geeks
雷峰网
雷峰网
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
V
Vulnerabilities – Threatpost
S
Securelist
The Hacker News
The Hacker News
The Register - Security
The Register - Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
AI
AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Schneier on Security
Schneier on Security
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Hacker News: Front Page
博客园 - 司徒正美
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
Security Latest
Security Latest
Engineering at Meta
Engineering at Meta
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
U
Unit 42
V
V2EX
V2EX - 技术
V2EX - 技术
L
LINUX DO - 最新话题
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
Recorded Future
Recorded Future
P
Privacy & Cybersecurity Law Blog
美团技术团队
小众软件
小众软件
F
Fortinet All Blogs

博客园 - Nillson

传说中的Singleton.... 设计模式--简单工厂模式 策略模式 抽象类与接口 C# 实现的一个二叉树类 再谈代理 常见的排序方法 预定义,宏定义 连接符,数值运算与函数 复杂查询 数据库中的Index和View的理解 重载和重写 采用递归的方法获得一棵树的所有叶节点 .NET中的新概念整理 4月要看的书 System.Runtime.InteropServices浅见 挂个牛人 一篇关于如何写注释的文章,值得收藏 Vistual Studio 2005到Vistual Studio 2008的版本转换问题 Visual Studio 2008 的一个Bug
回顾一个面试题
Nillson · 2008-07-11 · via 博客园 - Nillson

关于算法面试了两个题目:第一个是判断两个平面内的矩形是否可能发生碰撞;第二个是要写出逐层遍历二叉树的算法。个人感觉都不是很难,下面给出我的思路和解法。

设计一个数据结构来表示矩形,并用该结构作为参数来实现判断两个巨型是否发生碰撞的函数。

struct Rectangle
    {
        public Point leftUp;
        public Point rightDown;
    }
    class HitCheck
    {
        private Rectangle rectA = new Rectangle();
        private Rectangle rectB = new Rectangle();
        public HitCheck(Rectangle recA, Rectangle recB)
        {
            rectA = recA;
            rectB = recB;
        }
        public bool IsHited()
        {
            if (rectA.leftUp.X > rectB.rightDown.X || rectA.rightDown.X < rectB.leftUp.X || rectA.leftUp.Y > rectB.rightDown.Y || rectA.rightDown.Y < rectB.leftUp.Y)//如果左矩形的右边框在右矩形左边,左边框在右矩形右边,上边框在右矩形下边,下边框在右矩形上边则不相交,反之相交。
            {
                return false;
            }
            else if (rectB.leftUp.X > rectA.rightDown.X || rectB.rightDown.X < rectA.leftUp.X || rectB.leftUp.Y > rectA.rightDown.Y || rectB.rightDown.Y < rectA.leftUp.Y)
            {
                return false;
            }
            return true;
        }
    }

设计一个算法来“逐层”遍历二叉树。