02 2019 档案
摘要:一、Redis定义 Redis是一个开源的,基于内存的数据结构存储,可用于数据库、缓存、消息中间件。 1.1 为什么要用Redis? Redis是基于内存的,常用作缓存的一种技术,并且Redis存储的方式是以key-value的形式。 我们发现这不就是Java的Map容器所拥有的特性吗,为什么还需要
阅读全文
摘要:一 工厂模式介绍 1.1 工厂模式的定义 先来看下GOF为工厂模式的定义: “Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Metho
阅读全文
摘要:一、单例模式介绍 1.1 定义 保证一个类仅有一个实例,并提供一个访问它的全局访问点。 1.2 为什么要用单例模式? 在我们的系统中,有一些对象其实我们只需要一个,比如说:线程池、缓存、对话框、注册表、日志对象、充当打印机、显卡等设备驱动程序的对象。事实上,这一类对象只能有一个实例,如果制造出多个实
阅读全文
摘要:Given a linked list, remove the n-th node from the end of list and return its head. Example: Note: Given n will always be valid. Follow up: Could you
阅读全文
摘要:Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middl
阅读全文
摘要:You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contai
阅读全文
摘要:Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to in
阅读全文
摘要:Remove all elements from a linked list of integers that have value val. Example: 【递归】
阅读全文
摘要:Given a singly linked list, determine if it is a palindrome. Example 1: Example 2: Follow up:Could you do it in O(n) time and O(1) space?
阅读全文
摘要:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe
阅读全文
摘要:Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look
阅读全文
摘要:22 23 24 25 26 27 28 1 21 44 45 46 47 48 29 2 20 43 58 59 60 49 30 3 19 42 57 64 61 50 31 4 18 41 56 63 62 51 32 5 17 40 55 54 53 52 33 6 16 39 38 37
阅读全文
摘要:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example
阅读全文
摘要:Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string.
阅读全文
摘要: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 posi
阅读全文
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and num
阅读全文
摘要:Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Input: "aba" Output: True Exa
阅读全文
摘要:Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "holle" Example 2: Input: "le
阅读全文
摘要:Given a non-negative integer c, your task is to decide whether there're two integers a and bsuch that a2 + b2 = c. Example 1: Input: 5 Output: True Ex
阅读全文
摘要:https://www.cnblogs.com/Roni-i/p/7774100.html https://www.cnblogs.com/Roni-i/p/9253303.html 几百年前就会双指针了,但是Java有些语法还不熟练。。 (ps:双指针利用序列的递增性
阅读全文
摘要:import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class Solution { private int start = 1; /** * 对flag的写入虽然加锁保证了线程安全,但由于读取时不是volatile所以...
阅读全文
摘要:如果当多个线程访问同一个可变的状态变量时没有使用合适的同步,那么程序就会出现错误。有三种方式可以修复这个问题: i、不在线程之间共享该状态变量 ii、将状态变量修改为不可变的变量 iii、在访问状态变量时使用同步 什么是线程安全性? A:我们可以将单线程的正确性近似定义为“所见即所知”。在对“正确性
阅读全文
摘要:1.Hash Map的数据结构? A:哈希表结构(链表散列:数组+链表)实现,结合数组和链表的优点。当链表长度超过8时,链表转换为红黑树。 transient Node<K,V>[] table; 2.HashMap的工作原理 A:HashMap底层是hash数组和单向链表实现,数组中的每个元素都是
阅读全文
摘要:public static int lcs(String str1, String str2) { int len1 = str1.length(); int len2 = str2.length(); int c[][] = new int[len1+1][len2+1]; for (int i = 0; i = c[i][j-1]) ...
阅读全文
摘要:https://www.hollischuang.com/archives/3280 一、基础篇 面向对象 什么是面向对象 面向对象、面向过程 面向对象的三大基本特征和五大基本原则 平台无关性 Java如何实现的平台无关 JVM还支持哪些语言(Kotlin、Groovy、JRuby、Jython、S
阅读全文
摘要:一.秒杀场景与其他场景比较 1)im系统,例如qq或微博,每个人都读自己的数据(好友列表、群列表、个人信息) 2)微博系统,每个人读你关注的人的数据,一个人读多个人的数据 3)秒杀系统,库存只有一份,所有人都会在集中的时间读和写这些数据,多个人读一个数据 例如:小米手机每周二秒杀,可能手机只有一万部
阅读全文
摘要:分布式 Docker【容器化引擎服务】 微服务思想【服务拆分,持续集成、持续交付、持续部署】 Kubernetes(k8s)【容器化部署,管理云平台中多个主机上的容器化的应用】 云计算【SaaS(软件即服务) 、PaaS(平台即服务) 、IaaS(基础架构即服务)】 Zookeeper【分布式协调服
阅读全文
摘要:STAR法则,即为Situation Task Action Result的缩写,具体含义是: Situation: 事情是在什么情况下发生 Task: 你是如何明确你的任务的 Action: 针对这样的情况分析,你采用了什么行动方式 Result: 结果怎样,在这样的情况下你学习到了什么 简而言之
阅读全文
摘要:输入一个链表,输出该链表中倒数第k个结点。 输入一个链表,输出该链表中倒数第k个结点。
阅读全文
摘要:在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。 例如,链表1->2->3->3->4->4->5 处理后为 1->2->5 在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。 例如,链表1->2->3->
阅读全文
摘要:请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则该路径不能再进入该格子。 例如下面的矩阵包含了一条 bfce 路径。(因为题目中的矩阵是用一维
阅读全文
摘要:把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。 Step1.和二分查找
阅读全文
摘要:链接:https://www.nowcoder.com/questionTerminal/54275ddae22f475981afa2244dd448c6来源:牛客网 用两个栈实现一个队列的功能? <分析>: 入队:将元素进栈A 出队:判断栈B是否为空,如果为空,则将栈A中所有元素pop,并push
阅读全文
摘要:给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回。注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针。 ①节点右孩子存在,则设置一个指针从该节点的右孩子出发,一直沿着指向左子结点的指针找到的叶子节点即为下一个节点; 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的
阅读全文
摘要:MySql驱动包 mysql-connector-java-5.1.7-bin.jar MyBatis的核心包和依赖包 mybatis-3.2.7.jar(核心包)asm-3.3.1.jar(依赖包)cglib-2.2.2.jar(依赖包)commons-logging-1.1.1.jar(依赖包)
阅读全文
摘要:普通二叉树 BST平衡二叉树
阅读全文
摘要:private boolean isBalanced = true; public boolean IsBalanced_Solution(TreeNode root) { height(root); return isBalanced; } public int height(TreeNode root) { ...
阅读全文
摘要:class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } public class Solution { public int Tree...
阅读全文
摘要:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class Solution { i...
阅读全文
摘要:/*输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建任何新的结点,只能调整树中结点指针的指向。 */ class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.va...
阅读全文