2017年12月19日

类加载(对象创建)顺序

摘要: (1) 父类静态代码块(包括静态初始化块,静态属性,但不包括静态方法) (2) 子类静态代码块(包括静态初始化块,静态属性,但不包括静态方法 ) (3) 父类非静态代码块( 包括非静态初始化块,非静态属性 ) (4) 父类构造函数 (5) 子类非静态代码块 ( 包括非静态初始化块,非静态属性 ) ( 阅读全文

posted @ 2017-12-19 21:58 夜的第八章 阅读(305) 评论(0) 推荐(0) 编辑

线性表,线性表和链表的区别

摘要: 转载:https://www.cnblogs.com/wincai/p/5893475.html 存储类别 顺序存储结构单链表 存储分配方式 用一段连续的存储单元依次存储线性表的数据元素 采用链式存储结构,用一组任意的存储单元存放线性表的元素 时间性能 查找O(1)、插入和删除O(n) 查找O(n) 阅读全文

posted @ 2017-12-19 21:52 夜的第八章 阅读(441) 评论(0) 推荐(0) 编辑

Implement int sqrt(int x).

摘要: 自己设计函数,实现求根号。x是非负整数。 Input: 8 Output: 2 当开出根号后有小数,则省略小数部分。。 思路:只要找到一个数a,a*a<=x而且(a+1)*(a+1)>x,则a就是开根号后的结果。 这里要注意:a*a因为<=x,不会溢出,但是(a+1)*(a+1)则可能会导致溢出。一 阅读全文

posted @ 2017-12-19 21:23 夜的第八章 阅读(142) 评论(0) 推荐(0) 编辑

Add Binary

摘要: Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 我们可以用StringBuiler来存放相加以后的结果,然后在reverse()就行 阅读全文

posted @ 2017-12-19 19:03 夜的第八章 阅读(125) 评论(0) 推荐(0) 编辑

Roman to Integer(将罗马数字转成整数)

摘要: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 将罗马数字转成阿拉伯数字。需要了解两者对应关系。 罗马数字共有7个,即I(1)、V( 阅读全文

posted @ 2017-12-19 17:01 夜的第八章 阅读(194) 评论(0) 推荐(0) 编辑

leetcode刷题指南

摘要: 转载自:http://blog.csdn.net/lnho2015/article/details/50962989 以下是我个人做题过程中的一些体会: 1. LeetCode的题库越来越大,截止到目前,已经有321个问题了。对于大多数人来说,没有时间也没有必要把所有题目都做一遍(时间充裕可以随意) 阅读全文

posted @ 2017-12-19 16:12 夜的第八章 阅读(2657) 评论(0) 推荐(0) 编辑

Length of Last Word

摘要: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word 阅读全文

posted @ 2017-12-19 15:42 夜的第八章 阅读(117) 评论(0) 推荐(0) 编辑

Maximum Subarray(最大子数组)

摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2, 阅读全文

posted @ 2017-12-19 15:25 夜的第八章 阅读(174) 评论(0) 推荐(0) 编辑

count-and-say

摘要: The count-and-say sequence is the sequence of integers with the first five terms as following: 1 is read off as "one 1" or 11.11 is read off as "two 1 阅读全文

posted @ 2017-12-19 14:55 夜的第八章 阅读(449) 评论(0) 推荐(0) 编辑

Search Insert Position

摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文

posted @ 2017-12-19 11:12 夜的第八章 阅读(109) 评论(0) 推荐(0) 编辑

remove element

摘要: Given an array and a value, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you 阅读全文

posted @ 2017-12-19 10:05 夜的第八章 阅读(122) 评论(0) 推荐(0) 编辑

伸展树--java

摘要: 文字转载自:http://www.cnblogs.com/vamei 代码转载自:http://www.blogjava.net/javacap/archive/2007/12/19/168627.html 我们讨论过,树的搜索效率与树的深度有关。二叉搜索树的深度可能为n,这种情况下,每次搜索的复杂 阅读全文

posted @ 2017-12-19 09:27 夜的第八章 阅读(648) 评论(0) 推荐(0) 编辑

导航