- 博客(93)
- 收藏
- 关注
原创 虚拟机垃圾回收相关知识整理(JVM GC)
Java内存区域介绍Java内存区域有如下几部分构成1、程序计数器:指示的是当前正在执行的机器指令的地址。2、本地方法栈:通过JNI调用本地方法时根据语言的类型建立相应的栈。3、Java栈Java栈是每个线程私有的,每个线程都有一个Java栈,栈中存放着一系列的栈帧(Stack Frame),JVM只能压入(push)和弹出(pop)栈帧这两
2017-08-15 17:03:05 352
原创 2018美团点评内推笔试编程题2
老师不想自己改试卷,于是让大家互相改试卷。把全班同学分为k组,每组有s(k)个同学,老师先选择一个组i,将这个组的所有试卷s(i)份都收上来放在讲台上然后再选择一个组j,从讲台上拿s(j)份试卷随机分给j组的同学,然后把j组的所有试卷收上来,放在讲台上试卷的最下方……重复上述过程,最后把剩余的试卷随机分给i组的s(i)个同学。但是这样分配试卷是有缺陷
2017-09-01 16:55:33 525 1
原创 2018美团点评内推笔试编程题1
思路:对于题目给定的数组,我们求数组的累加和数组sum,然后对于累加和数组sum中的任一个元素sum[i],j分别取0到i-1,当sum[i]-sum[j]是k的倍数时,i-j就是以以第j个元素结尾的长度最长的子串的长度。因此,我们只要遍历i就能求出k倍数的最长子串的长度。代码:import java.util.Scanner; p
2017-09-01 16:51:05 962
原创 遍历Map的四种方法
public static void main(String[] args) { Map map = new HashMap(); map.put("1", "value1"); map.put("2", "value2"); map.put("3", "value3"); //第一种:普遍使用,二次取值 System.out.println("通过
2017-08-27 22:18:14 248
原创 牛客网笔试输入的问题(Java)
今天在做滴滴出行内推笔试的编程题碰到了这个问题耽误了很长时间,然而网上也没有答案,因此记录下来,方便自己查阅复习,也方便需要的小伙伴!代码如下-----滴滴2018内推的编程题:package 内推笔试;import java.util.Arrays;import java.util.Scanner;/** * Created by liuming on 2017/8/26.
2017-08-26 17:49:27 18749
原创 Longest Substring Without Repeating Characters leetcode java
题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is
2017-08-24 22:58:57 184
原创 Length of Last Word leetocde java
题目: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 wo
2017-08-24 22:52:28 153
原创 Jump Game II leetcode java
题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your
2017-08-24 22:15:33 212
原创 Jump Game leetcode java
题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Dete
2017-08-24 21:58:17 177
原创 Longest Common Prefix leetcode java
题目:Write a function to find the longest common prefix string amongst an array of strings. 题解:解题思路是,先对整个String数组预处理一下,求一个最小长度(最长前缀肯定不能大于最小长度)。然后以第0个字符串作为参照,从第1个字符串到最后一个字符串,对同一位置做判断,
2017-08-24 16:01:05 178
原创 Java基础部分(一)
1、一个".java"源文件中是否可以包括多个类(不是内部类)?有什么限制? 可以有多个类,但只能有一个public的类,并且public的类名必须与文件名相一致。2、Java有没有goto? java中的保留字,现在没有在java中使用。3、说说&和&&的区别。 &和&&都可以用作逻辑与的运算符,表示逻辑与(and),当运算符两边的表达式的结果
2017-08-23 22:24:42 152
原创 IntelliJ 快捷输出方式
今天偶然发现了IntelliJ中 创建main函数的快捷键,依次还有for循环,System.out.println();在编写代码的时候直接输入psv就会看到一个psvm的提示,此时点击tab键一个main方法就写好了。psvm 也就是public static void main的首字母。依次还有在方法体内键入for会有一个fori的提示,选中然后tab键,就会
2017-08-23 12:03:57 4540
原创 Combinations
原题 Given two integers n and k, return all possible combinations of k numbers out of 1 … n. For example, If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3],
2017-08-21 21:56:51 136
原创 Sort Colors leetcode java
原题 Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the
2017-08-21 21:22:57 170
原创 Container With Most Water leetcode java
题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). nvertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0
2017-08-21 20:10:59 195
原创 Divide Two Integers leetcode java
题目:Divide two integers without using multiplication, division and mod operator.public int divide(int dividend, int divisor) { if (dividend == 0 || divisor == 0) { return
2017-08-21 19:20:13 224
原创 N-Queens leetcode java
题目:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens
2017-08-21 18:51:30 178
原创 什么是二维数组
1、二维数组如何定义Java语言中,多维数组被看作数组的数组。 定义方式和一维数组类似,如下:type arrayName[ ][ ]; type [ ][ ]arrayName;12122、二维数组如何初始化二维数组初始化和一维数组一样,分为静态初始化和动态初始化静态初始化 Java语言中,由于把二维数组看作是数组的数组,数组空间不是连续分配的,所
2017-08-21 15:50:03 3913
原创 _XmnXmsXmxXss有什么区别
Reference:http://blog.csdn.net/ooppookid/article/details/515309321、XmnXmsXmxXss有什么区别首先,Xmn、Xms、Xmx、Xss都是JVM对内存的配置参数,我们可以根据不同需要区修改这些参数,以达到运行程序的最好效果。了解jvm内存管理看这里:jvm是如何管理内存的Xms、Xmx-X
2017-08-21 15:16:48 544
原创 进程间通信方式
管道(pipe)及有名管道(named pipe):管道可用于具有亲缘关系进程间的通信,有名管道除了具有管道所具有的功能外,它还允许无亲缘关系进程间的通信。信号(signal):信号是在软件层次上对中断机制的一种模拟,它是比较复杂的通信方式,用于通知进程有某事件发生,一个进程收到一个信号与处理器收到一个中断请求效果上可以说是一致得。消息队列(message queue):消息队
2017-08-20 22:05:26 142
原创 SpringMVC 的工作原理和机制
第一步:发起请求到前端控制器(DispatcherServlet)第二步:前端控制器请求HandlerMapping查找 Handler 可以根据xml配置、注解进行查找第三步:处理器映射器HandlerMapping向前端控制器返回Handler第四步:前端控制器调用处理器适配器去执行Handler第五步:处理器适配器去执行Handler第六步:Handler执行完成给适配器
2017-08-20 21:58:14 1014
原创 Single Number II leetcode java
题目:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it with
2017-08-20 20:09:31 129
原创 Single Number leetcode java
题目:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without us
2017-08-20 20:02:03 140
原创 Java——HashSet和TreeSet的区别
HashSetHashSet有以下特点 不能保证元素的排列顺序,顺序有可能发生变化 不是同步的 集合元素可以是null,但只能放入一个null当向HashSet集合中存入一个元素时,HashSet会调用该对象的hashCode()方法来得到该对象的hashCode值,然后根据 hashCode值来决定该对象在HashSet中存储位置。简单的说,HashSet集合判断两
2017-08-20 19:57:14 218
原创 Longest Consecutive Sequence leetcode java
题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [
2017-08-20 19:44:20 136
原创 Surrounded Regions leetcode java
题目:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O
2017-08-20 19:26:24 143
原创 Evaluate Reverse Polish Notation leetcode java
题目:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2",
2017-08-20 19:14:55 141
原创 Simplify Path leetcode java
题目:Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c" Corner Cases:Did you consider the
2017-08-20 18:44:42 161
原创 Longest Valid Parentheses leetcode java
题目:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()
2017-08-19 20:05:51 161
原创 Maximal Rectangle leetcode java
题目:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. 题解: 这道题可以应用之前解过的Largetst Rectangle in Histogram一题辅助解决。解决方法是:
2017-08-18 20:18:55 166
原创 Largest Rectangle in Histogram leetcode java
题目:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where
2017-08-18 18:29:20 227
原创 Sort List leetcode java
题目: Sort a linked list in O(n log n) time using constant space complexity. 题解:考虑到要求用O(nlogn)的时间复杂度和constant space complexity来sort list,自然而然想到了merge sort方法。同时我们还已经做过了merge k sorted list
2017-08-17 21:10:28 147
原创 Reorder List leetcode java
题目:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder
2017-08-17 20:25:33 153
原创 Faster\Slower 快慢指针的应用
leetcode很多题目都是利用快慢指针来解决题目,下面具体讲解下快慢指针。 概念: 快指针在每一步走的步长要比慢指针一步走的步长要多。快指针通常的步速是慢指针的2倍。在循环中的指针移动通常为:faster = faster.next.next, slower = slower.next. 应用:1. 用来找中点或中位数2. 用来判断链表
2017-08-17 20:22:28 255
原创 Merge k Sorted Lists leetcode java
题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题解:Merge k sorted linked list就是merge 2 sorted linked list的变形题。而且我们很自然的就想到了经典的M
2017-08-17 20:05:20 110
原创 Reverse Nodes in k-Group leetcode java
题目: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 a
2017-08-17 19:52:35 177
原创 Add Two Numbers leetcode java
题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as
2017-08-17 19:43:51 122
原创 Spring官网下载dist.zip的几种方法
Reference:http://www.cnblogs.com/yjmyzz/p/3847364.htmlSpring官网改版后,很多项目的完整zip包下载链接已经隐掉了,虽然Spring旨在引导大家用更“高大上”的maven方式来管理所依赖的jar包,但是完全没想到中国的国情,在伟大的墙内,直接通过maven下载墙外的东西,要么龟速,要么直接被和谐。下面是从网上搜集的一些方
2017-08-17 11:59:24 171
原创 Copy List with Random Pointer leetcode java
题目: 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. 题解:如果要cop
2017-08-16 22:11:05 136
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人