自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(53)
  • 问答 (3)
  • 收藏
  • 关注

原创 搜狐笔试Kolakoski数列

暴力解法 有更优解欢迎讨论一下纸~import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in

2017-08-30 19:00:46 314

原创 Leetcode11(Java)

Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lin

2017-08-10 16:14:11 283

原创 Leetcode 645(Java)

The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of on

2017-07-30 14:57:26 554

原创 Leetcode 152(Java)

Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest produ

2017-07-29 18:29:37 585

原创 Leetcode 605(Java)

Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die.Given a

2017-07-27 11:19:58 541

原创 Leetcode 628(Java)

Given an integer array, find three numbers whose product is maximum and output the maximum product.Example 1: Input: [1,2,3] Output: 6 Example 2: Input: [1,2,3,4] Output: 24 Note: The length of

2017-07-27 10:27:34 416

原创 八大排序算法(Java实现)

在介绍所有算法之前,先引入排序算法稳定性的概念。若Ai=Aj,在排序之前的乱序数组中,Ai在Aj之前,排序后,Ai仍在Aj之前。则说这个排序算法具有稳定性。需要注意的是,排序算法是否为稳定的是由具体算法决定的,不稳定的算法在某种条件下可以变为稳定的算法,而稳定的算法在某种条件下也可以变为不稳定的算法。 分析算法稳定与否的意义在于:当要排序的内容是一个复杂对象的多个数字属性,且其原本的初始顺序存在意

2017-07-10 17:13:48 612

原创 Leetcode 169&229(Java)

这是两道数组中找元素的题目,229是169的进阶版。先看169。Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty

2017-06-10 10:11:45 331

原创 Leetcode 155(Java)

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the

2017-06-09 09:49:31 596

原创 Leetcode 21(Java)

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.题目很简单有很简短,实际上对于链表的题目很容易想到递归的方法。新建一个头节点,不断拿两个链表的节点比较,谁小就链接上去。

2017-06-07 11:07:04 1404

原创 Leetcode 400(Java)

Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …Note: n is positive and will fit within the range of a 32-bit signed integer (n < 231).Example 1:Input: 3Output

2017-06-06 14:04:46 568

原创 Leetcode 151(Java)

Total Accepted: 154413 Total Submissions: 982629 Difficulty: Medium Contributor: LeetCode Given an input string, reverse the string word by word.For example, Given s = “the sky is blue”, return “

2017-06-03 18:16:17 474

原创 Leetcode 58(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 word is defined as

2017-06-02 22:12:18 626

原创 Servlet生命周期详解

之前转过一篇讲解servlet生命周期的文章,今天午睡之前发现自己还是没有办法很好的梳理一遍。想起我麻麻的教育语录:好记性不如烂笔头。Servlet程序是运行在服务器端的一段java程序,其生命周期将受到web容器的控制。生命周期包括加载程序、初始化、服务、销毁、卸载这五个部分。加载servlet Web容器主要负责加载servlet,当Web容器启动时,或者当第一次使用这个servlet时,容器

2017-05-31 21:57:02 523

原创 JSP中四中属性的范围

在JSP中提供了4中属性的保存范围。保存范围也就是一个内置对象,可以在多少个页面中保存并继续使用。概述如下:page:(页面级别)只在一个页面中个保存属性,跳转之后无效request:(请求级别)只再一次请求中保存属性,服务器跳转依然有效session:(用户级别)再一次回话范围中保存,无论何种跳转都可以使用,但是新开浏览器后无法使用application:(会话级别)在整个服务器上保存,所

2017-05-27 21:45:11 435

原创 Leetcode 392(Java)

Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, an

2017-05-20 22:03:04 360

原创 Leetcode 481(Java)

A magical string S consists of only ‘1’ and ‘2’ and obeys the following rules:The string S is magical because concatenating the number of contiguous occurrences of characters ‘1’ and ‘2’ generates the

2017-05-19 14:09:40 327

原创 Leetcode 89(Java)

The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray

2017-05-17 18:26:28 525

原创 Leetcode 22(Java)

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ “((()))”, “(()())”, “(())()”, “()(())”,

2017-05-16 16:17:17 446

原创 Leetcode 409(Java)

Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example “Aa” is not consider

2017-05-15 20:58:20 615

原创 Leetcode 1(Java)

Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same ele

2017-05-14 16:24:21 251

原创 Leetcode 203(Java)

Remove all elements from a linked list of integers that have value val.Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5链表类问题的解决通常要复刻一个链表,建立一个空头。再用两个指针遍历一遍链表,遇到符合的

2017-05-13 09:10:40 529

原创 Leetcode 404(Java)

Find the sum of all left leaves in a given binary tree.Example:3/ \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.sum为所以左枝叶子结点

2017-05-12 08:55:46 652

原创 Leetcode 506(Java)

Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: “Gold Medal”, “Silver Medal” and “Bronze Medal”.Example 1: Input: [5

2017-05-08 18:23:27 246

原创 Leetcode 575(Java)

Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these

2017-05-07 16:15:35 390

原创 Leetcode 566(Java)

In MATLAB, there is a very useful function called ‘reshape’, which can reshape a matrix into a new one with different size but keep its original data.You’re given a matrix represented by a two-dimensio

2017-05-06 15:57:26 452

原创 Leetcode 371(Java)

Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example: Given a = 1 and b = 2, return 3.Credits: Special thanks to @fujiaozhu for adding this problem a

2017-04-27 12:33:48 565

转载 Servlet生命周期与工作原理

Servlet生命周期分为三个阶段:  1,初始化阶段 调用init()方法  2,响应客户请求阶段  调用service()方法  3,终止阶段  调用destroy()方法Servlet初始化阶段:  在下列时刻Servlet容器装载Servlet:    1,Servlet容器启动时自动装载某些Servlet,实现它只需要在web.XML文件中的之间添加如下代码:1     2,在Ser

2017-04-23 21:40:52 172

原创 Leetcode 463(Java)

Total Accepted: 35307 Total Submissions: 62217 Difficulty: Easy Contributors: amankaraj You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water

2017-04-22 10:06:01 293

原创 Java三大核心集合类详解

在Java三大核心集合类中,有两个(List、Set)都继承自Collection,它的重要性不言而喻。因此在介绍三大集合框架之前,我们先要了解Collection。Collection位于java.util包中,是一个集合接口(集合类的一个顶级接口)。它提供了对集合对象进行基本操作的通用接口方法。 既然讲到了集合,什么是集合?集合的本质上是一种容器,而我们所熟知的数组本质上也是一种容器,它们二者

2017-04-20 22:24:39 2434 1

原创 Java可见性之内存模型

Java内存模型概述Java内存模型(Java Memory Model)描述了Java线程中各种共享变量的访问规则,以及在JVM中将共享变量写入内存和从内存中读出共享变量的底层细节。 在一般的Java程序中,都有一个主内存,这个主内存中存放了所有的共享变量。而在每个线程中,又拥有属于自己的独立的工作内存。这个工作内存了保留了该线程使用的公共变量的一份copy。如下图所示:在JMM中有两条规定:

2017-04-19 16:20:52 251

原创 Linux之PATH环境变量的配置

假设程序a.out的绝对路径是/bin/ls,运行cat时,我们总要在命令行完整的输入绝对路径,这太麻烦了。而配置环境变量则可以让我们仅仅输入a.out就可以运行程序。 Linux系统中,系统程序位于目录/bin、/usr/bin目录下,设置PATH环境变量的值为/bin:/usr/bin,PATH环境变量中可以保存多个目录,使用:隔开,输入可执行程序名cat,系统会依在/bin、/usr/bin

2017-04-18 19:38:22 1186

原创 Leetcode 207(Java)

There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair:

2017-04-18 14:18:27 695

原创 Linux之常用Shell命令

Shell是一个命令处理器,是一个读入并解释你输入的指令的C语言程序。可以说Shell是使用者和Linux之间的桥梁,通过shell命令,我们才能和Linux对话。接下来将分别从“格式”、“功能”、“例子”来介绍Linux文件系统中常用的shell命令:目录管理类ls命令 格式:ls [选项] [文件] 功能:列出目录内容 例子: ls 列出当前目录下的文件 ls /home 列出/h

2017-04-17 13:50:04 474

原创 Linux与Windows文件系统的差异比较

在Linux中,很多基本命令都与文件系统有关。而Linux的文件系统与我们所熟知的Windows文件系统的差别很大,主要体现在以下两个方面: 1.路径名分割符不同 2.路径的结构不同windows系统中的路径名分割符为\ Linux系统中的路径名分割符则是/ windows中的路径名分割符与众多编程语言的转义字符相同,在编程时要尤其注意。例如: 在C程序中打开C:\Windows\read

2017-04-17 13:04:36 12334 1

原创 Leetcode 387(Java)

Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.Examples:s = “leetcode” return 0.s = “loveleetcode”, return 2. Note: You may assume

2017-04-17 12:20:29 319

原创 Leetcode 112&113&437(Java)

今天来总结一下Leetcode上目前我做到关于Path Sum即二叉树求和的内容,涉及的题目有三道,题号为112(easy),113(medium),437(easy)。Leetcode 112Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the

2017-04-15 22:24:31 502

原创 TCP协议的“三握四挥”过程简述

TCP协议的连接建立与连接释放是计算机网络的基础,也是很重要的内容。 首先要明确的是,TCP的运输连接管理分为三个阶段:建立连接、数据传送、连接释放。这篇文章主要分析的是建立连接和释放连接的过程。 其次,TCP连接的建立采用了C/S模式(即客户机-服务器模式),因此,接下来的分析都将以此为基础。初始状态:在最开始的时候,客户机与服务器各司其职,并没有发生连接。TCP协议建立连接的三次握手过程:假

2017-04-14 15:49:02 5198 2

原创 Leetcode 389(Java)

Leetcode 389

2017-04-14 13:53:10 331

原创 Leetcode 127(Java)

Leetcode 127

2017-04-13 21:04:49 704

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除