注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
1. 把url输入进浏览器跳转网页的过程发生了什么. Χ
2.process之间怎么交流
3.http和https有什么区别?. Χ
4.process和thread有什么区别?
5.有什么design pattern
6.写一下java singleton.1point3acres
- // not thread safe. Waral dи,
- public class Singleton {
- private static Singleton instance;
- private Singleton (){}
- .--
- public static Singleton getInstance() { . 1point3acres
- if (instance == null) { . ----
- instance = new Singleton();
- }
- return instance;
- }
- }
复制代码
- // thread safe. check 1point3acres for more.
- public class Singleton { -baidu 1point3acres
- private static Singleton instance;
- private Singleton (){}
- public static synchronized Singleton getInstance() {
- if (instance == null) {
- instance = new Singleton();
- }
- return instance; . ----
- }
- }
复制代码
写一下atoi
- ublic int myAtoi(String str) {
- // if input string is empty, return 0
- if (str == null || str.isEmpty())
- return 0;.google и
- // save input string size
- int n = str.length();
- // skip spaces
- int index = 0; ..
- while (index < n && str.charAt(index) == ' ') {. check 1point3acres for more.
- index++;
- }
- // reached the end of string, return 0
- if (index == n) ..
- return 0;
- .google и
- // calculate sign. From 1point 3acres bbs
- int sign = str.charAt(index) == '-' ? -1 : 1;
- . check 1point3acres for more.
- // move to next char if sign is present
- if (str.charAt(index) == '-' || str.charAt(index) == '+') {
- index++;
- }
- // reached the end of string, return 0
- if (index == n)
- return 0;.1point3acres
- . 1point3acres.com
- // calculate max value without last digit
- // -2,147,483,647 -> -2,147,483,64
- int max = Integer.MAX_VALUE / 10;
- // calculate last digit
- // 2,147,483,647 -> 7 or -2,147,483,648 -> 8-baidu 1point3acres
- int lastMaxDigit = sign > 0 ? Integer.MAX_VALUE - max * 10 : -(Integer.MIN_VALUE + max * 10);
- // result without sign
- int number = 0;. Χ
- // loop until end or until character is digit
- while (index < n && str.charAt(index) >= '0' && str.charAt(index) <= '9') {.--
- // convert character to digit
- int digit = str.charAt(index) - '0';
- // if number is greater than max without last digit
- // or number is equal max without last digit but last digit is greater then max last digit
- // return integer max or min, depend on sign
- if (number > max || number == max && digit >= lastMaxDigit) {
- return sign > 0 ? Integer.MAX_VALUE : Integer.MIN_VALUE;
- }
- // accumulate current digit to result
- number = number * 10 + digit;
- // move to next character.--
- index++;
- }
- // add sign to number and return result. Waral dи,
- return sign * number;
- }
复制代码
. From 1point 3acres bbs
补充内容 (2019-8-20 15:39):
附一个楼主准备面试的时候从newcoder爬下来的面经:
https://docs.google.com/document ... jU/edit?usp=sharing |