自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 收藏
  • 关注

原创 [LeetCode]3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "b", with the le

2017-11-24 10:01:50 207

原创 《设计模式之禅》读书笔记(四)之抽象工厂模式

《设计模式之禅》读书笔记(四)之抽象工厂模式一、抽象工厂模式的定义 Provide an Interface for creating families of related or dependent objects without specifying their concrete classes.(为创建一组相关或相互依赖的对象提供一个接口,而且无需指定他们的具体类。)抽象工厂模式的通用类

2017-11-20 22:50:40 276

原创 《设计模式之禅》读书笔记(三)之扩展工厂方法模式

工厂模式的扩展主要四种:简单工厂模式、多工厂模式、替代单例模式、延迟初始化。

2017-11-19 22:41:12 218

原创 《设计模式之禅》读书笔记(二)之工厂方法模式

工厂方法模式的定义为: Define an interface for creating an object , but let subclass decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

2017-11-16 14:43:38 254

原创 [LeetCode] 654. Maximum Binary Tree

Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:The root is the maximum number in the array.

2017-11-13 14:54:34 233

原创 《设计模式之禅》读书笔记(一)——单例模式

单例模式是一个比较简单的模式,定义如下:Ensure a class has only one instance, and provide a global point of access to it.(确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例)1.饿汉式/** * * @Title: Singleton * @description: 单例模式-饿汉式 *

2017-11-13 14:44:10 202

原创 [javaScript]身份证号信息解析

之前一直在思考是不是该把工作中一些问题写出来(可能是简单的问题),现在的想法是应该写出来这些简单的问题。虽然工作中可能并没有很多特别难的问题让你去解决,因为公司的招人就是根据你的能力来匹配的嘛。简单的问题大部分都能从网上找到,比如数字校验的正则表达式、邮箱的校验、网址匹配的正则表达式等等。有时候我们遇到的问题并不是正好跟网上已有的完全一致,比如根据身份证显示出性别、出生年月、年龄的功能有不少,但

2017-11-13 14:44:05 1635

原创 Python学习笔记:与Java 基础语法对比

闲着无聊学习下Python 的语法。由于我目前主要编程语言还是Java ,所以针对Python 的学习我主要是通过与Java 进行对比。我使用的是Python3,因此语法上也会遵循Python3 的规则。简介Python是一种解释型、面向对象、动态数据类型的高级程序设计语言。Python由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年。像Perl语

2017-11-13 14:44:02 419

原创 每个产品经理都该懂点技术(一)——前后端做什么?

每个产品经理都应该懂点技术。当技术人员认为你提出的需求不能实现而怼你的时候,你可以从技术的角度将他正面击倒。而且熟悉一定的技术后,产品经理提出的需求将会更加合理,技术人员实现起来更容易。达到产品和技术和谐共处的美好社会。此篇文章是该系列的第一篇。产品经理每天需要跟技术人员打交道。有时候我们想知道,我提出的需求技术人员究竟能不能实现?要搞清楚这个问题,我们需要知道技术人员是怎么工作的,他们不同的

2017-11-13 14:43:59 3175

原创 Java Mail 邮件发送简单封装

上一篇文章我们用写了一个Java Mail 的Demo,相信你已经可以用那个例子来发送邮件了。但是Demo 有很多的问题。首先每次发送需要配置的东西很多,包括发件人的邮箱和密码、smtp服务器和SMTP端口号等信息。其次,没有将发送和邮件内容相分离。按照单一职责原则,应该有且仅有一个原因引起类的变更[^设计模式]。最后一个问题是,我们的代码不仅自己用,也很可能让别人调用。别人调用的时候不想去了解

2017-11-13 14:43:57 536

原创 Java Mail 邮件发送Demo

上周公司的项目要求开发邮件发送功能。自己在网上跟着教程边学边做了一下午,现在基本开发完成了。由于一个同事也想看下该怎么写,顺便学习下。所以我就写成了一遍教程,顺便巩固下邮件发送里面的内容。Demo第一步,我们先写个Demo,用最快的方式最少的代码向你展示Java Mail 是如何工作的。我的开发环境是:JDK1.6java-mail.jar 1.45构建一个简单的邮件发送,一共需

2017-11-13 14:43:54 296

原创 Win10下配置Java 环境变量

在Win10中配置环境变量的方法跟在Win8和Win7中有些不同,看了看网上好多还是Win7/8里面的配置方法。虽然从原理上基本上没什么问题,但有些细节却会让人很苦恼。特意整理下新的配置方法。我假定你已经正确安装了JDK和JRE。1. 配置JAVA_HOME首先打开环境变量的配置界面,新建一个系统环境变量:变量名:JAVA_HOME变量值:E:\JDK\JDK1.8其中变量值为你的

2017-11-13 14:43:51 277

原创 Java对map进行排序并生成序号

最近做的项目有这样一个需求:要求对map中的值进行排序并生成序号。如果值相等则序号不变;如果不相等序号为该数数值在所有元素中的索引。如下表所示:Key(String)Value(Float)Idx2312.41103.22112.2392.2311.9560.56public static Integer get

2017-11-13 14:43:49 2664

原创 [JavaScript]YYYY-MM-DD格式字符串计算年龄

function getAge(birth){ birth = birth.replace(/-/g,"/"); //把格式中的"-"替换为"/" birth = new Date(birth ); //替换后转为Date类型 var now = new Date(); //获取当前日期 var nowYear=now.getFullYear(); //当前日期的年

2017-11-13 14:43:44 1193

原创 MySQL中变量的用法——LeetCode 178. Rank Scores

Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the next ranking number should be the next consecutive integer value.

2017-11-13 14:43:39 405

原创 LeetCode(476): Number Complement

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is guaranteed to fit within the range of a 32

2017-11-13 14:43:34 229

原创 树的层次遍历(Java代码实现)

与树的前中后序遍历的DFS思想不同,层次遍历用到的是BFS思想。一般DFS用递归去实现(也可以用栈实现),BFS需要用队列去实现。层次遍历的步骤是:1.对于不为空的结点,先把该结点加入到队列中2.从队中拿出结点,如果该结点的左右结点不为空,就分别把左右结点加入到队列中3.重复以上操作直到队列为空  1 public class Solution{ 2 class TreeNode

2017-11-13 14:43:29 5514

原创 解决使用eclipse创建maven web项目时报Could not resolve archetype的问题

前两天重装了系统,今天想写一个项目的时候出现了点问题。在使用eclipse创建maven web项目时,点Finish后报了Could not resolve archetype的问题。Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:1.0 from any of the confi

2017-11-13 14:43:24 1154

原创 回顾:计算机网络之传输协议

今天面试真是超级难受。之前面试的公司问的都是项目,我准备的东西也就偏向项目了一点。然而,今天面试的面试官特别倾向于基础。结果,快排没写出来,一个简单的算法题,解题的思路跟面试官提示的不大一样。准备接下来花一段时间好好复习回顾下以前学的计算机网络、数据结构、数据库、操作系统的内容。 TCP是面向连接的可靠数据传输服务,还有拥塞控制机制。简单地说,当双方之间网络阻塞时,TCP可以抑制发送进程。

2017-11-13 14:43:19 191

原创 Java使用BigDecimal解决精确计算的问题

最近有人在微信上给我发了一个数学题目,如下图:我看了之后感觉很是简单,但是却想了半天才解出来。解出来后我想到了用程序再解一遍,然而精确计算的问题却让人头疼不已。解题思路:思路其实很简单,暴力求解就可以,但是当你写了一个四重for循环后你会发现解不出来。由此考虑到结果可能是小数,便把增量改成了float类型,每次自增0.1。当你写完满心欢喜地运行的时候会发现还是出不来结果。再改成doubl

2017-11-13 14:43:14 290

原创 Leetcode(93): Restore IP Addresses

Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order does not

2017-11-13 14:43:10 130

原创 LeetCode(144):Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3].Note: Recursive solution is

2017-11-13 14:43:05 140

原创 LeetCode (238):Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n).

2017-11-13 14:43:00 136

原创 LeetCode (262):Nim Game

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the

2017-11-13 14:42:55 147

原创 LeetCode (236):Lowest Common Ancestor of a Binary Search Tree

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between

2017-11-13 14:42:51 210

原创 LeetCode (226):Invert Binary Tree 递归实现

Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this original tweet by Max Ho

2017-11-13 14:42:46 122

原创 LeetCode (65):Same tree

Total Accepted: 83663 Total Submissions: 200541 Difficulty: Easy Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are

2017-11-13 14:42:41 135

原创 LeetCode (237):Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3

2017-11-13 14:42:36 133

原创 LeetCode (258):Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one dig

2017-11-13 14:42:32 168

原创 C++求矩阵的鞍点

矩阵的鞍点就是指它在本行中的值最大,在本列中的值最小。求解思路:求出每行的最大值MaxRow以及每列的最小值MinColumn保存行最大值的位置和列最小值的位置如果行最大值得位置和列最小值的相等则输出此鞍点(如果没有鞍点则输出无)代码如下:#include #includeusing namespace std;int main(){ int

2017-11-13 14:42:27 11944 1

原创 Java Swing简单的加法器

1 package test; 2 import java.awt.*; 3 import javax.swing.*; 4 import java.awt.event.*; 5 public class FrameDemo2 6 { 7 static JTextField field1=new JTextField(5); 8 static JTextField fi

2017-11-13 14:42:22 2855

原创 简单的Java网络爬虫(获取一个网页中的邮箱)

1 import java.io.BufferedReader; 2 import java.io.FileNotFoundException; 3 import java.io.FileReader; 4 import java.io.IOException; 5 import java.io.InputStreamReader; 6 import java.net.URL;

2017-11-13 14:42:17 712

原创 C++DFS方法全排列

前几天看纪磊的《啊哈!算法》一书,里面讲算法讲的特别通俗细致,真的是初中生都能读得懂的算法书(我大二才读:P)。这段代码很适合初学算法的同学。#includeusing namespace std;int a[10], book[10], n;//全排列算法,运用深度优先搜索dfsvoid dfs(int step){ int i; if (st

2017-11-13 14:42:12 3306 1

原创 蓝桥杯练习——C++输出阶乘的最右边一位非零数

1 #include 2 #include 3 using namespace std; 4 #define M 10000 5 #define N 10000 6 int p=1; 7 int func2(int a); 8 void func(int *a,int n) 9 { 10 int i,j,k; 11 for(j=2;j) 12 {

2017-11-13 14:42:10 938

原创 C/C++中RAND_MAX的用法

RAND_MAX是C中stdlib.h中宏定义的一个字符常量:#define RAND_MAX Ox7FFF其值最小为32767,最大为2147483647通常在产生随机小数时可以使用RAND_MAX。给出C++例子://在VC6.0中运行通过#include#include#includeusing namespace std;int main(void)

2017-11-13 14:42:03 24633

原创 C++利用系统时间产生的随机数

本文由青松原创并依GPL-V2及其后续版本发放,转载请注明出处且应包含本行声明。C++中常用rand()函数生成随机数,但严格意义上来讲生成的只是伪随机数(pseudo-random integral number)。生成随机数时需要我们指定一个种子,如果在程序内循环,那么下一次生成随机数时调用上一次的结果作为种子。但如果分两次执行程序,那么由于种子相同,生成的“随机数”也是相同的。在工程应用时,

2017-11-13 14:41:58 2492

转载 C语言 gets()和scanf()函数的区别

scanf( )函数和gets( )函数都可用于输入字符串,但在功能上有区别。若想从键盘上输入字符串"hi hello",则应该使用__gets__函数。gets可以接收空格;而scanf遇到空格、回车和Tab键都会认为输入结束,所有它不能接收空格。char string[15]; gets(string); /*遇到回车认为输入结束*/scanf("%s",string); /*遇到

2017-11-13 14:41:53 207

空空如也

空空如也

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

TA关注的人

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