- 博客(133)
- 资源 (11)
- 收藏
- 关注
转载 Java 类加载过程
一个 Class 类在JVM 中的生命周期如下:类加载的过程包含了加载、验证、准备、解析、初始化五个阶段。有时候也会将验证、准备、解析这三个阶段称为链接阶段。其中,加载、验证、准备和初始化这四个阶段发生的顺序是确定的,而解析阶段则则不一定,他在某些情况下可以初始化之后开始,这是为了支持 Java 语言的运行时绑定(也称为动态绑定或晚期绑定)这几个阶段是按顺序开始,而不是按顺序进行或完成的...
2019-12-05 20:21:30
390
原创 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 does not exist, return 0.Note: A word is defined...
2019-12-05 18:58:00
476
原创 关于 equals() 和 hashCode()方法
Object 类作为 Java 中所有对象的超类提供了以下方法:我们来看一看 JDK1.8中对于 equals()方法的描述:可以看到提醒我们如果重写了 equals()方法一定要重写 hashCode 方法。我们再来看一看对于 hashCode() 方法的描述:这个地方说明了三个事:对同一个对象的多次 hashCode()方法调用应该返回同一个值一个对象的equals()方法...
2019-12-04 20:45:57
819
原创 Simplify Path
Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path.In a UNIX-style file system, a period . refers to the current directory. Furthermore, ...
2019-12-04 20:10:40
213
原创 Valid Anagram
Given two strings s and t , write a function to determine if t is an anagram of s.Example 1:Input: s = “anagram”, t = “nagaram”Output: trueExample 2:Input: s = “rat”, t = “car”Output: falseNote...
2019-12-02 21:01:06
344
原创 关于快速失败(fail-fast)和安全失败(fail-safe)的区别
fail-fast和fail-safe比较Iterator 的安全失败是基于对底层集合做拷贝,因此,它不受集合上的修改的影响。java.util 包下面所有的集合类都是安全失败的。快速失败的迭代器会抛出 ConcurrentModificationException 异常,而安全失败的迭代器永远不会抛出这样的异常。快速失败示例import java.util.ArrayList;impor...
2019-11-26 20:59:52
588
原创 Longest Common Prefix
描述Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.Example 1:Input: [“flower”,“flow”,“flight”]Output: ...
2019-11-26 20:26:40
131
原创 Wildcard Matching
描述Implement wildcard pattern matching with support for ‘?’ and ‘’.‘?’ Matches any single character. '’ Matches any sequence of characters (including the empty sequence).The matching should cover th...
2019-11-25 21:02:38
140
原创 Add Binary
描述Given two binary strings, return their sum (also a binary string).For example,a = “11”b = “1”Return 100.分析无// Add Binary// 时间复杂度O(n),空间复杂度O(1)class Solution { public String addBinary(S...
2019-11-22 18:50:16
211
原创 ArrayList 和 Vector 的区别
首先这两个类都实现了 List 接口,而实现 List 接口一共三个类,Vector、ArrayList 和 LikedList。List 用于存放多个元素,能够维护元素的次序,并且允许元素重复,这三个类之间的相同与不同如下:底层数据结构区别,ArrayList 和 Vector 底层都通过数组实现,而 LinkedList 则通过链表实现。不同的数据结构决定了他们的特性,利用数组实现的 Ar...
2019-11-21 21:02:11
205
原创 String to Integer (atoi)
Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this...
2019-11-21 20:46:21
145
原创 Implement strStr()
描述Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.分析暴力算法的复杂度是 O(m*n),代码如下。更高效的的算法有KMP算法、Boyer-Mooer算法和Rabin-Karp算法。面试中...
2019-11-20 23:00:43
164
原创 如何把数据库的多行搜索结果聚合成一行
1.首先我们需要了解下什么是聚合函数聚合函数aggregation function又称为组函数。 认情况下 聚合函数会对当前所在表当做一个组进行统计。2.聚合函数的特点1.每个组函数接收一个参数(字段名或者表达式) 统计结果中默认忽略字段为NULL的记录2.要想列值为NULL的行也参与组函数的计算,必须使用IFNULL函数对NULL值做转换。3.不允许出现嵌套 比如sum(max(xx...
2019-11-18 19:09:10
450
原创 Valid Palindrome
描述Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,“A man, a plan, a canal: Panama” is a palindrome. “race a car” is not a pa...
2019-11-18 19:02:42
185
原创 234. Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: trueFollow up:Could you do it in O(n) time and O(1)...
2019-11-15 10:23:25
254
原创 LRU Cache---如何实现一个简单的 LRU 缓存
描述Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if ...
2019-11-13 22:07:27
196
原创 Reorder List
描述:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You may not modify the values in the list’s nodes, only nodes itself may be changed.Example 1:Given 1->2-...
2019-11-12 21:42:33
178
原创 Linked List Cycle II
描述Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up: Can you solve it without using extra space?分析当fast与slow相遇时,slow肯定没有遍历完链表,而fast已经在环内循环了n圈...
2019-11-11 20:04:56
161
原创 OAuth 协议
OAuth:一个关于授权(authorization)的开放网络标准,目前版本是2.0版。OAuth 协议 1.0 授权步骤应用向服务提供方申请请求令牌(Request Token),服务提供方验证通过后将令牌返回。这个步骤由于涉及到应用账号密码,在应用服务端发起,所以这个步骤对用户透明。应用使用请求令牌让浏览器重定向到服务提供方进行登录验证和授权。服务提供方校验请求令牌,将第三方的资料显...
2019-11-11 10:26:58
199
原创 Linked List Cycle
Given a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail con...
2019-11-10 20:01:05
144
原创 Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.Example 1:Input:{“KaTeX parse erro...
2019-11-09 22:37:01
144
原创 Reverse Nodes in k-Group
描述Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is...
2019-11-06 18:15:05
302
原创 Rotate List
Rotate List描述Given a list, rotate the list to the right by k places, where k is non-negative.For example: Given 1->2->3->4->5->nullptr and k = 2, return 4->5->1->2->3->...
2019-11-05 19:36:41
132
原创 Remove Duplicates from Sorted List II
描述Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1-&g...
2019-11-04 19:00:22
134
原创 Remove Duplicates from Sorted List
描述Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3./...
2019-11-04 18:45:41
137
原创 Partition List
描述Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of...
2019-10-31 17:35:21
169
原创 Reverse Linked List II
描述Reverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->nullptr, m = 2 and n = 4,return 1->4->3->2->5->nullptr....
2019-10-29 18:53:47
136
原创 关于 RocketMQ中 GroupID 与 Topic 订阅关系的疑问
问题在阿里云服务提供的消息队列服务(RocketMQ)中,给出了一份关于订阅关系一致的最佳实践,在文档中指出同一个 GroupID 中的所有消费者实例最好订阅同样的 Topic+Tag。这让我有一些疑问,为什么一个 GroupID 只能产生一种订阅,这样岂不是同一个应用需要订阅不同的 Topic 那么每一次都需要去申请一个 GroupID,这使得 GroupID 和 Topic 产生了一定的耦合...
2019-10-29 17:48:27
25885
4
原创 第五届阿里云中间件天池大赛总结
云生不知处队伍初赛两个指标:争取尽可能多的完成率。(三个 provider 的一共 1300+个线程,consumer 只有 1024 个线程,靠线程数分配即可做到 100%的完成率)争取尽量多的完成数(运用两个指标,tps 和 cpu 使用率,因为测试环境通过 sleep 来模拟请求处理,所以 CPU 使用率不会上升,只能依靠 tps 来作为负载均衡的指标)复赛整体设计:最...
2019-10-29 17:26:41
874
1
原创 Redis应用---Redis可以用来做什么?
Redis可以用来干什么?1.记录帖子的点赞数、评论数和点击数(hash)2.记录用户的梯子ID列表(排序),便于快速显示用户的帖子列表(zset)。3.记录帖子的标题、摘要、作者和封面信息,用于列表页展示。(hash)4.记录帖子的点赞用户ID列表,评论ID列表,用于显示和去重计数。(zset)5.缓存近期热帖内容(帖子内容空间占用比较大),减少数据库压力(hash)。6.记录帖子...
2019-01-06 17:49:57
2441
原创 分布式锁概念及实现方式
分布式锁概念及其实现方式分布式锁概念什么是锁?在单进程的系统中,当存在多个线程可以同时改变某个变量(可变共享变量)时,就需要对变量或代码块做同步,使其在修改这种变量时能够线性执行,以防止并发修改变量带来不可控的结果。同步的本质是通过锁来实现的。为了实现多个线程在一个时刻同一个代码块只能有一个线程可执行,那么需要在某个地方做个标记,这个标记必须每个线程都能看到,当标记不存在时可以设置该标记...
2018-12-24 21:32:45
750
原创 移动零
给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。示例:输入: [0,1,0,3,12]输出: [1,3,12,0,0]说明:必须在原数组上操作,不能拷贝额外的数组。尽量减少操作次数。答案:class Solution { public void moveZeroes(int[] nums) { if(nums =...
2018-11-18 23:35:58
200
原创 最长上升子序列
题目描述:给定一个无序的整数数组,找到其中最长上升子序列的长度。示例:输入: [10,9,2,5,3,7,101,18]输出: 4解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4。说明:可能会有多种最长上升子序列的组合,你只需要输出对应的长度即可。你算法的时间复杂度应该为 O(n2) 。进阶: 你能将算法的时间复杂度降低到 O(n log n) 吗?时间复杂度...
2018-10-29 00:11:25
173
原创 Dubbo注册中心挂掉之后,是否还可以继续通信?
注册中心中任意一台机器宕机之后,可以切换到另一台主机上。如果所有的主机都宕机了,还可以依赖本地缓存进行通信。
2018-04-05 20:38:43
7135
1
原创 单例模式
单例模式一、什么是单例模式单例模式,是一种常用的软件设计模式。在它的核心结构中只包含一个被称为单例的特殊类。通过单例模式可以保证系统中,应用该模式的类一个类只有一个实例。即一个类只有一个对象实例二、单例模式的特点单例模式只能有一个实例单例模式必须创建自己的唯一实例单例类必须向其他对象提供这一实例三、单例模式的实现懒汉模式public clas...
2018-02-27 12:37:05
253
原创 java线程池源码解读
java线程池自己实现的一个线程池IThreadPoolpackage pool;import java.util.List;/** * @author Mingming * @Description * @Date Created in 11:29 2018/2/22 * @Modificd By */public interface IThreadPoo...
2018-02-22 13:12:49
402
原创 Linux查看文件内容的命令
Linux查看文件内容的命令cat:从第一行开始显示内容,并将所有内容输出 cat语法:cat [-n] 文件名 (-n : 显示时,连行号一起输出)tac:从最后一行开始显示内容,并将所有内容输出head:只显示前几行 head的语法:head [n number] 文件名 (number 显示行数)tail:只显示后几行 tail的语法:tail ...
2018-02-08 23:34:17
561
原创 mysql使用的引擎
mysql使用的引擎①Mylsam 不支持事务,适用于选择密集型,插入密集型,mysql默认的引擎②innodb 适用于更新密集型,支持事务,自动灾难恢复,行级锁,外键约束③memory出发点是速度,采用逻辑存储介质是内存④merge 一组myisam 表的集合...
2018-02-08 23:33:15
375
原创 JVM分区
JVM分区jvm的分区有程序计数器、虚拟机栈、本地方法栈、方法区、堆。程序计数器(线程私有):一块较小的内存空间,他的作用可以看做是当前线程所执行的字节码的行号指示器。在虚拟机的概念模型里(仅仅是概念模型,各种虚拟机可能会有更高效的实现方式),字节码解释器的工作就是通过改变这个计数器的值来选取下一条需要执行的字节码指令,分支、循环、跳转、异常处理、线程恢复等基础功能都需要这个计数器来完成。Java虚
2018-02-07 23:43:19
433
原创 通过maven的tomcat插件启动web工程时出错
在使用maven构建web工程时,使用tomcat插件启动出现下面的错误。具体表现为tomcat起不起来。"C:\Program Files\Java\jdk1.7.0_80\bin\java" -Dmaven.multiModuleProjectDirectory=F:\code\JAVA\JAVAcode\work2\javaconfigdemo -Dmaven.home=F:\java\
2018-01-17 16:32:43
1051
j2EE核心模式
2017-09-26
Struts2权威指南
2017-09-26
Struts2技术内幕
2017-09-26
log4j入门到详解
2017-09-26
MySQL必知必会
2017-09-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人