diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/exercies.md" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/exercies.md" new file mode 100644 index 0000000000000000000000000000000000000000..15d5bd11fb1a96ed84e92634952d498522fef5fa --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/exercies.md" @@ -0,0 +1,33 @@ +# 覆盖面积 + +给你 二维 平面上两个 由直线构成且边与坐标轴平行/垂直 的矩形,请你计算并返回两个矩形覆盖的总面积。 + +每个矩形由其 左下 顶点和 右上 顶点坐标表示: + +第一个矩形由其左下顶点 (ax1, ay1) 和右上顶点 (ax2, ay2) 定义。 +第二个矩形由其左下顶点 (bx1, by1) 和右上顶点 (bx2, by2) 定义。 + +参数限制: +-10e4 <= ax1, ay1, ax2, ay2, bx1, by1, bx2, by2 <= 10e4 + +## 输入描述 +第一个矩形由其左下顶点 (ax1, ay1) 和右上顶点 (ax2, ay2) 坐标 +第二个矩形由其左下顶点 (bx1, by1) 和右上顶点 (bx2, by2) 坐标 +## 输出描述 +两个矩形覆盖的总面积. + +# 示例 + +## 示例 1: + +输入:ax1 = -3, ay1 = 0, ax2 = 3, ay2 = 4, bx1 = 0, by1 = -1, bx2 = 9, by2 = 2 +输出:45 + +## 示例 2: + +输入:ax1 = -2, ay1 = -2, ax2 = 2, ay2 = 2, bx1 = -2, by1 = -2, bx2 = 2, by2 = 2 +输出:16 + +# 提示 +无. + diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/solution.java" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/solution.java" new file mode 100644 index 0000000000000000000000000000000000000000..87d9abdd83047cebb5a62862b9f6cb8e06fe9670 --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/solution.java" @@ -0,0 +1,8 @@ +class Solution { + public int computeArea(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2) { + int area1 = (ax2 - ax1) * (ay2 - ay1), area2 = (bx2 - bx1) * (by2 - by1); + int overlapWidth = Math.min(ax2, bx2) - Math.max(ax1, bx1), overlapHeight = Math.min(ay2, by2) - Math.max(ay1, by1); + int overlapArea = Math.max(overlapWidth, 0) * Math.max(overlapHeight, 0); + return area1 + area2 - overlapArea; + } +} \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/1.in" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/1.in" new file mode 100644 index 0000000000000000000000000000000000000000..6ad5f7adf6c49703f2ee9ffc97383f7b5a5fd808 --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/1.in" @@ -0,0 +1,8 @@ +-3 +0 +3 +4 +0 +-1 +9 +2 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/1.out" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/1.out" new file mode 100644 index 0000000000000000000000000000000000000000..7d37386284a97324cbac474cb5ea5360d361d104 --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/1.out" @@ -0,0 +1 @@ +45 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/10.in" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/10.in" new file mode 100644 index 0000000000000000000000000000000000000000..7a6440037d7128a86decad5ad7c496ad65354d6a --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/10.in" @@ -0,0 +1,8 @@ +-10 +-10 +0 +0 +-10 +-10 +0 +0 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/10.out" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/10.out" new file mode 100644 index 0000000000000000000000000000000000000000..105d7d9ad3afc7bb78a0dec4d829880831605dfb --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/10.out" @@ -0,0 +1 @@ +100 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/2.in" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/2.in" new file mode 100644 index 0000000000000000000000000000000000000000..f61d8196f23716835f6e6a7a08f684491c22eb6c --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/2.in" @@ -0,0 +1,8 @@ +0 +0 +0 +0 +0 +0 +0 +0 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/2.out" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/2.out" new file mode 100644 index 0000000000000000000000000000000000000000..c227083464fb9af8955c90d2924774ee50abb547 --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/2.out" @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/3.in" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/3.in" new file mode 100644 index 0000000000000000000000000000000000000000..e2b82c7793bf485531d3d0a32acad85f9abbc973 --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/3.in" @@ -0,0 +1,8 @@ +-100 +-100 +100 +100 +-100 +-100 +100 +100 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/3.out" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/3.out" new file mode 100644 index 0000000000000000000000000000000000000000..7030076e245dac1f46f5d9e6eee1613d0dd93f7d --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/3.out" @@ -0,0 +1 @@ +40000 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/4.in" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/4.in" new file mode 100644 index 0000000000000000000000000000000000000000..bc7a5032f7943efc9039dc06d11682b9863d2f9a --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/4.in" @@ -0,0 +1,8 @@ +-1 +-1 +1 +1 +-1 +-1 +1 +1 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/4.out" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/4.out" new file mode 100644 index 0000000000000000000000000000000000000000..bf0d87ab1b2b0ec1a11a3973d2845b42413d9767 --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/4.out" @@ -0,0 +1 @@ +4 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/5.in" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/5.in" new file mode 100644 index 0000000000000000000000000000000000000000..8d2e0f484acca99a06a435985c2c0b327b796940 --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/5.in" @@ -0,0 +1,8 @@ +-10 +-10 +10 +10 +-10 +-10 +10 +10 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/5.out" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/5.out" new file mode 100644 index 0000000000000000000000000000000000000000..6b3ed8d68b037971d3b708a8060117ea8b6afbac --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/5.out" @@ -0,0 +1 @@ +400 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/6.in" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/6.in" new file mode 100644 index 0000000000000000000000000000000000000000..be90ef95cd749c740d08deac7f39f3f1b4db528d --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/6.in" @@ -0,0 +1,8 @@ +-5 +-5 +5 +5 +-5 +-5 +5 +5 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/6.out" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/6.out" new file mode 100644 index 0000000000000000000000000000000000000000..105d7d9ad3afc7bb78a0dec4d829880831605dfb --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/6.out" @@ -0,0 +1 @@ +100 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/7.in" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/7.in" new file mode 100644 index 0000000000000000000000000000000000000000..0f6ffe0a129f23a4ee73a653d60a053f013c9cde --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/7.in" @@ -0,0 +1,8 @@ +-1 +-1 +0 +0 +-1 +-1 +0 +0 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/7.out" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/7.out" new file mode 100644 index 0000000000000000000000000000000000000000..56a6051ca2b02b04ef92d5150c9ef600403cb1de --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/7.out" @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/8.in" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/8.in" new file mode 100644 index 0000000000000000000000000000000000000000..834f93211ad37cb6196dc3f8a4292d4e435389d7 --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/8.in" @@ -0,0 +1,8 @@ +0 +0 +1 +1 +0 +0 +1 +1 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/8.out" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/8.out" new file mode 100644 index 0000000000000000000000000000000000000000..56a6051ca2b02b04ef92d5150c9ef600403cb1de --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/8.out" @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/9.in" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/9.in" new file mode 100644 index 0000000000000000000000000000000000000000..a1ec51d373de69e9beaf2f175a20761b6bc5393c --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/9.in" @@ -0,0 +1,8 @@ +0 +0 +10 +10 +0 +0 +10 +10 \ No newline at end of file diff --git "a/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/9.out" "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/9.out" new file mode 100644 index 0000000000000000000000000000000000000000..105d7d9ad3afc7bb78a0dec4d829880831605dfb --- /dev/null +++ "b/exercises/chenguangjian/\344\270\255\347\255\211/\350\246\206\347\233\226\351\235\242\347\247\257/test_cases/9.out" @@ -0,0 +1 @@ +100 \ No newline at end of file diff --git "a/exercises/chenguangjian/\345\233\260\351\232\276/\346\261\202\350\247\243\347\247\251\347\237\251\351\230\265/exercises.md" "b/exercises/chenguangjian/\345\233\260\351\232\276/\346\261\202\350\247\243\347\247\251\347\237\251\351\230\265/exercises.md" index ac970431b7397cd8f810a21303df1ebee8a26cec..4506e8ea9b3b8d9a5601e981c28291147a1b0c2e 100644 --- "a/exercises/chenguangjian/\345\233\260\351\232\276/\346\261\202\350\247\243\347\247\251\347\237\251\351\230\265/exercises.md" +++ "b/exercises/chenguangjian/\345\233\260\351\232\276/\346\261\202\350\247\243\347\247\251\347\237\251\351\230\265/exercises.md" @@ -16,7 +16,7 @@ m == matrix.length n == matrix[i].length 1 <= m, n <= 500 --10^9 <= matrix[row][col] <= 10^9 +-10e9 <= matrix[row][col] <= 10e9 # 示例 diff --git "a/exercises/chenguangjian/\351\235\236\347\274\226\347\250\213\351\242\230/\351\242\230\347\233\256.md" "b/exercises/chenguangjian/\351\235\236\347\274\226\347\250\213\351\242\230/\351\242\230\347\233\256.md" index d3a305cfa8cfb6b64bc7fc19523f962124863417..9116eca0d851b794ae3ad8cd4f819b64e649e47e 100644 --- "a/exercises/chenguangjian/\351\235\236\347\274\226\347\250\213\351\242\230/\351\242\230\347\233\256.md" +++ "b/exercises/chenguangjian/\351\235\236\347\274\226\347\250\213\351\242\230/\351\242\230\347\233\256.md" @@ -30,15 +30,14 @@ 解析:MapReduce是一种用于大数据处理的分布式计算模型。它可以将大数据集分成许多小的数据块进行并行处理,然后将结果整合在一起。SQL和NoSQL都是用于数据存储的技术,而不是数据处理的技术。手写代码虽然可以完成大数据处理,但是不如使用现有的技术方便和高效。 -4. OLAP(联机分析处理)是指什么? - A. 一种数据库管理系统 - B. 一种数据仓库 - C. 一种数据处理技术 - D. 一种数据挖掘算法 +4. OLAP(在线分析处理)主要用于支持以下哪种类型的查询: + A. 事务处理查询 + B. 聚合查询 + C. 实时查询 + D. 文本查询 - 答案:C - - 解析:OLAP(Online Analytical Processing,联机分析处理)是一种数据处理技术,用于多维数据分析和查询。它可以对大量数据进行快速的复杂分析和查询,以支持商业智能和决策支持系统。数据仓库则是存储数据的地方,而OLAP是对数据仓库中的数据进行处理和分析的技术。 + 答案:B + 解析:OLAP(在线分析处理)是一种针对多维数据仓库设计的技术,主要用于支持复杂的聚合查询,如数据挖掘、报表生成等。与事务处理查询(如增删改查)相比,OLAP 更注重对大量数据进行高效的汇总和分析。 5. ACID是什么意思? A. 一种数据库管理系统