26.广度优先&深度优先

20190918005018.png


25.贪心算法:leetcode122

problem

Say you have an array for which the ith element is the price of a given stock on day i.

Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).

Note: You may not engage in multiple transactions at the same time (i.e., you must sell the stock before you buy again).


23.分治:leetcode-169

problem

Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.

You may assume that the array is non-empty and the majority element always exist in the array.

Example 1:

1
2
3
4
5
6
Input: [3,2,3]
Output: 3
Example 2:

Input: [2,2,1,1,1,2,2]
Output: 2

21.递归和分治:leetcode-50

Implement pow(x, n).

eg. 2^2 = 2^1 * 2^1 = (2^0 * 2^0 * 2) * (2^0 * 2^0 * 2) = (1 * 1 * 2) * (1 * 1 * 2) = 4

eg. 2^3 = 2^1 * 2^1 * 2 = (2^0 * 2^0 * 2) * (2^0 * 2^0 * 2) * 2 = (1 * 1 * 2) * (1 * 1 * 2) * 2 = 8


Java常用类库

Java异常体系

Error和Exception的区别

  • Error:程序无法处理的系统错误,编译器不做检查
  • Exception:程序可以处理异常,捕获后可以恢复
  • 总结:前者程序无法处理,后者是可以处理的异常

Java框架-Spring

SpringIOC (Inversion of Control) 控制反转

  • SpringCore最核心部分
  • 需要先了解依赖注入(DependencyInversion)

Java多线程和并发-原理

synchronized

线程安全的主要诱因

  • 存在共享数据
  • 存在多条线程共同操作这些共享数据
  • 根本方法:同一时刻有且只有一个线程在操作共享数据,其他线程必须等到该线程处理完数据后再对共享数据进行操作

Java多线程和并发

进程和线程的区别

//TODO linux用户态和内核态是如何进行转换,为什么要转换,什么是系统中断,它的内核态的多线程是如何通过轻量级线程方式实现


Java底层:GC

标记算法

引用计数算法(不适合循环引用)

  1. 通过判断对象的引用数量来决定对象是否可以被回收
  2. 每个对象实例都有一个引用计数器,被引用则+1,完成引用则-1
  3. 任何引用计数为0的对象实例可以被当做垃圾收集

优点: 执行效率高,程序执行受影响较小

缺点: 无法检测出循环引用的情况,导致内存泄露


Java底层:JVM

谈谈你对java的理解

  • 平台无关性
  • GC
  • 语言特性
  • 面向对象
  • 类库
  • 异常处理

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×