Algorithm

4. Median of Two Sorted Arrays

  • What 两个排序数组的中位数

  • How 两个数组合并到同一个数组,然后进行排序取中间值即可

  • Key Codes

class Solution {
public double findMedianSortedArrays(int[] nums1, int[] nums2) {
int m = nums1.length;
int n = nums2.length;
int num[] = new int[m+n];
for(int i=0;i<m;i++){
num[i]=nums1[i];
}
for(int i=m;i<m+n;i++){
num[i]=nums2[i-m];
}
for(int i=0;i<m+n;i++){
for(int j=i+1;j<m+n;j++){
if(num[j]<num[i]){
int temp;
temp=num[i];
num[i]=num[j];
num[j]=temp;
} }
} if((m + n)% 2 ==0) return (double)(num[(m+n)/2-1]+num[(m+n)/2])/2;
else return num[(m+n)/2]; }
}

Review

You don't have enough tests and you never will!

  • What 讲的是软件是一项复杂的协作练习,我们永远不会有足够的测试来捕获可能出错的所有内容,但通过正确的测试策略和设计,将能够生成高质量的软件,而不会因编写和维护太多测试而陷入困境。

Tip

  • WhatIDEA的一些快捷键

  • How在代码编辑器中,按快捷键ALT+Insert,弹出菜单可以选自动生成的选项,可以生成生成getter 和setter等方法,为节省了我们很多时间。

  • psvm 生成main方法

  • sout 生成控制台输出

  • psf 生成公共静态final

  • psfs 生成公共静态final String

  • psfi 生成公共静态 final int

  • ...

Share

  • 作为一名程序员应该具备哪些素质
  • 团队精神和协作能力
  • 规范化,标准化的代码编写习惯
  • 需求理解能力
  • 测试习惯
  • 学习和总结的能力

2018-08-01-weekly的更多相关文章

  1. 2018.08.01 BZOJ4552: [Tjoi2016&Heoi2016]排序(二分+线段树)

    传送门 线段树简单题. 二分答案+线段树排序. 实际上就是二分答案mid" role="presentation" style="position: relat ...

  2. Cheatsheet: 2018 08.01 ~ 2018 10.31

    Other Building the Ultimate Developer PC 3.0 - The Parts List for my new computer, IronHeart Face re ...

  3. 【2018.08.01】(表/栈/队列/大小顶堆)学习Stark和Queue算法小记

    Train Problem I As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of st ...

  4. http://www.cnblogs.com/stephen-liu74/archive/2012/08/01/2561557.html

    http://www.cnblogs.com/stephen-liu74/archive/2012/08/01/2561557.html

  5. Intel Digital Innovation Industry Summit(2018.08.17)

    时间:2018.08.17地点:北京金隅喜来登大酒店

  6. Trusted Cloud Summit(2018.08.14)

    时间:2018.08.14地点:北京国际会议中心

  7. (转)新手C#SQL语句的学习2018.08.13

    1.创建数据库(create) CREATE DATABASE database-name 2.删除数据库(drop) drop database dbname 3.备份数据库 --- 创建 备份数据 ...

  8. 新手C#SQLServer在程序里实现语句的学习2018.08.12

    从C#中连接到SQL Server数据库,再通过C#编程实现SQL数据库的增删改查. ado.net提供了丰富的数据库操作,这些操作可以分为三个步骤: 第一,使用SqlConnection对象连接数据 ...

  9. 新手C#SQL Server使用记录2018.08.10

    主键(PrimaryKey):主键就是每个数据行(记录)的唯一标识,不会有重复值的列(字段)才能当做主键.一个表可以没有主键,但是这样会很难处理表,因此一般情况表都要设置主键. 主键有两张选用策略,分 ...

  10. 新手C#异常的学习2018.08.07

    异常是在程序执行期间出现的问题.C# 中的异常是对程序运行时出现的特殊情况的一种响应,比如尝试除以零. class Program { static void Main(string[] args) ...

随机推荐

  1. fengmiantu3

  2. 【adb真机查Log】Android Studio 3.X 找不到Android Device Monitor

    参考来源:https://blog.csdn.net/yuanxiang01/article/details/80494842 以下信息来源于Android Developers官网 Android设 ...

  3. Idea导入项目详解

    1.点击Import Project选择项目所在目录 2.Import Project选项区别: 1)如果选择Create project from existing sources选项, 则你只能导 ...

  4. 佳能mp288拆解步骤--绝对原创

    http://itbbs.pconline.com.cn/office/50663206.html 佳能mp288拆解步骤--绝对原创 gotobug Lv1太平洋舰队新兵 楼主 2013-10-13 ...

  5. unity编辑器Hierarchy添加图标

    效果 素材 using UnityEditor; using UnityEngine; using System.Collections.Generic; [InitializeOnLoad] cla ...

  6. mooc-IDEA 使用界面--001

    IntelliJ IDEA 快捷键应用小结 1.Ctrl+E :  打开最近所有浏览过的文件 2.Ctrl+Shift+E :打开最近所有编辑修改过的文件 3.ctrl+shift+Backspace ...

  7. C语言第七周作业

    每个单词的最后一个字母改成大写 函数fun的功能是:将p所指字符串中每个单词的最后一个字母改成大写.(这里的"单词"是指由空格隔开的字符串). 函数接口定义: void fun( ...

  8. Sentinel整合Dubbo限流实战(分布式限流)

    之前我们了解了 Sentinel 集成 SpringBoot实现限流,也探讨了Sentinel的限流基本原理,那么接下去我们来学习一下Sentinel整合Dubbo及 Nacos 实现动态数据源的限流 ...

  9. <每日一题> Day3:CodeForces-1141B.MaximalContinuousRest(简单题)

    题目链接 参考代码: #include <iostream> #include <algorithm> using namespace std; + ; int value[m ...

  10. document.domain location.hostname location.host

    document.domain    location.hostname     location.host   :https://www.cnblogs.com/shd-study/p/103031 ...