自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Lnho的专栏

发表是最好的记忆

  • 博客(157)
  • 收藏
  • 关注

原创 关于$'\r': command not found错误的一点体会

今天运行一个其他组开发的jar包,这个jar包由于运行参数是通过命令行的方式输入的,所以需要运行一个shell脚本来启动。 启动脚本类似这样:#!/bin/bashjdbc_driverClassName=com.mysql.jdbc.Driverjdbc_url=jdbc:mysql://XX/XX?characterEncoding=UTF-8jdbc_username=XXjdbc_

2016-05-05 13:47:32 46347 1

原创 Leet Code OJ 15. 3Sum[Difficulty: Medium]

题目: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: Elements in a triplet (a,b,c) must

2016-05-04 13:21:46 6585

原创 CentOS下Hive2.0.0单机模式安装详解

本文环境如下: 操作系统:CentOS 6 32位 Hive版本:2.0.0 JDK版本:1.8.0_77 32位 Hadoop版本:2.6.41. 所需要的环境Hive 2.0需要以下运行环境: Java 1.7以上(强烈建议使用Java 1.8) Hadoop 2.X2. 下载、解压Hive安装包Hive官网地址: http://hive.apache.org/

2016-05-03 20:23:38 14047

原创 Leet Code OJ 28. Implement strStr() [Difficulty: Easy]

题目: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.翻译: 实现一个方法strStr()。返回字符串needle第一次在字符串haystack出现的下标,如果needle不是haysta

2016-04-28 16:46:25 4477

原创 Java解析HttpClient获取的Json字符串报错Expected BEGIN_OBJECT but was STRING

当前程序通过HttpClient调用一个php接口,对方返回了一个Json格式的字符串。 但是获取后用Gson解析报如下错误:Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at

2016-04-22 09:34:07 11196

原创 CentOS下Storm 1.0.0集群安装详解

本文环境如下: 操作系统:CentOS 6 32位 ZooKeeper版本:3.4.8 Storm版本:1.0.0 JDK版本:1.8.0_77 32位 Python版本:2.6.6 集群情况:一个主控节点(Master)和两个工作节点(Slave1,Slave2)1. 搭建Zookeeper集群安装参考:CentOS下ZooKeeper单机模式、集群模式安装2

2016-04-13 15:16:19 15124

原创 CentOS下ZooKeeper单机模式、集群模式安装

本文环境如下: 操作系统:CentOS 6 32位 ZooKeeper版本:3.4.80. 环境需求Zookeeper需要JDK1.6以上版本的Java环境 可以参考: CentOS 6使用rpm方式安装JDK81. 下载软件包到ZooKeeper官网上http://zookeeper.apache.org/下载软件包,例如:wget "http://apache.opencas.

2016-04-13 13:42:58 10090

原创 CentOS 6 安装Hadoop 2.6 (四)运行简单例子

CentOS 6 安装Hadoop 2.6 (一)准备工作 CentOS 6 安装Hadoop 2.6 (二)配置Hadoop CentOS 6 安装Hadoop 2.6 (三)问题收集 CentOS 6 安装Hadoop 2.6 (四)运行简单例子1.新建输入文件mkdir ~/inputcd ~/input vi file1写入Hello world haha good

2016-04-11 15:23:13 5064

原创 CentOS 6 安装Hadoop 2.6 (三)问题收集

排查错误的重要途径就是检查日志文件,如果按照上文的配置方法,配置文件在/opt/hadoop-2.6.4/logs/底下,主要需要关注的是后缀是log的几个文件。先检查你的主节点,再检查从节点。1. 日志中出现XXX连接不上,一直重试这种情况在从节点的日志中很常见。(1) 确认hosts文件是否配置正确以下是笔者的master节点的hosts文件127.0.0.1 localhost local

2016-04-11 12:38:03 2647

原创 CentOS 6 安装Hadoop 2.6 (二)配置Hadoop

CentOS 6 安装Hadoop 2.6 (一)准备工作 CentOS 6 安装Hadoop 2.6 (二)配置Hadoop下文服务器描述:一个主节点master,2个从节点slave1和slave2。1. 解压文件tar -xzvf hadoop-2.6.4.tar.gzmv hadoop-2.6.4 /opt/2. 配置环境变量vi etc/profile到末尾增加以下内容HADOOP_H

2016-04-11 12:01:15 3298 1

原创 CentOS 编译Hadoop 2.6 32位

本文采用CenOS 6 32位,JDK1.7进行编译 (1)安装编译库yum install cmake lzo-devel zlib-devel gcc gcc-c++ autoconf automake libtool ncurses-devel openssl-devel libXtst(2)安装mavenwget http://repos.fedorapeople.org/repos/dc

2016-04-08 12:50:33 2238 1

转载 CentOS 6使用rpm方式安装JDK8

(1)安装之前,先检查一下系统中是否已经有安装jdkrpm -qa | grep java如果有可以使用rpm -qa | grep java | xargs rpm -e --nodeps批量卸载所有带有Java的文件 (2)在官网下载jdk-8u77-linux-i586.rpm 因为Oracle官网现在有加下载权限认证,所以无法直接通过某个地址下载。但是我们可以在官网点击下载按钮触发下载操

2016-04-08 10:08:21 12075 1

原创 Linux配置SSH无密码登录

下文以配置2台主机无密码登录为例,本机名为master,另外一台机子名为slave11. 配置主机名分别修改2台机子的主机名为master和slave1,具体方法:CentOS修改主机名(hostname)2. 配置hosts在2台主机上都执行以下操作,当前服务器放第一行vi /etc/hosts增加2行115.10.20.1 master //前面为对应主机的ip地址115.10.20.2 sl

2016-04-07 20:48:37 1361 1

转载 CentOS修改主机名(hostname)

需要修改两处:一处是/etc/sysconfig/network,另一处是/etc/hosts,只修改任一处会导致系统启动异常。首先切换到root用户。/etc/sysconfig/network用任一款你喜爱的编辑器打开该文件,里面有一行 HOSTNAME=localhost.localdomain (如果是默认的话),修改 localhost.localdomain 为你的主机名。/etc/ho

2016-04-07 20:16:42 1913

原创 Ubuntu常用服务器环境搭建——Nginx+PHP篇

1.安装Nginxapt-get install nginx2.启动Nginxservice nginx start3.访问服务器IP 如果看到“Welcome to nginx!”说明安装好了。 4.安装PHPapt-get install php5-fpm5.配置Nginxvi /etc/nginx/sites-available/default找到下列代码,去掉相应注释location ~

2016-03-31 14:17:15 7798

原创 Ubuntu常用服务器环境搭建——MySQL篇

MySQL1.安装MySQLapt-get updateapt-get install mysql-server2.配置MySQLvi /etc/mysql/my.cnf /** 也可能是/etc/mysql/mysql.conf.d/mysqld.cnf,里面要包含[mysqld]的配置**/在[mysqld] 添加以下项character_set_server=utf8skip-name-

2016-03-31 13:04:39 2933

原创 Leet Code OJ 14. Longest Common Prefix [Difficulty: Easy]

题目: Write a function to find the longest common prefix string amongst an array of strings.翻译: 写一个函数去找到在字符串数组里面的最长的前缀字符串。分析: 首先考虑字符串数组的length为0和为1的情况,为1的情况如果不预先处理,后面判断起来会比较麻烦。然后需要找出这些字符串的最短的长度,超过这个长度

2016-03-25 18:36:12 1534

原创 jedisPool.getResource()方法长时间无响应并且不报错

一个Java Web的系统需要动态根据Redis地址获取数据,截取相关代码如下:获取连接的方法:public static JedisCluster getConn(String host, int port) { String key = getKey(host, port); JedisCluster jedisCluster = (JedisCluster)jedisCon

2016-03-25 14:11:44 9679

原创 Leet Code OJ 125. Valid Palindrome [Difficulty: Easy]

题目: 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

2016-03-25 13:20:39 2928

原创 Leet Code OJ 20. Valid Parentheses [Difficulty: Easy]

题目: Given a string containing just the characters , determine if the input string is valid.The brackets must close in the correct order, “()” and “()[]{}” are all valid but “(]” and “([)]” are not.翻译:

2016-03-24 13:22:19 4907

原创 LeetCode刷题指南(一)

以下是我个人做题过程中的一些体会: 1. LeetCode的题库越来越大,截止到目前,已经有321个问题了。对于大多数人来说,没有时间也没有必要把所有题目都做一遍(时间充裕可以随意)。刷个100题左右应该就差不多了(可以考虑序号为前100多的题目,相对更经典一点)。 2. 从AC率高的开始做,难度从简单->中等,先不要做困难的。 3. 可以按照下文的面试出题频率顺序来做,从频率最高的一批开始。

2016-03-23 15:02:40 116636 11

原创 Leet Code OJ 2. Add Two Numbers [Difficulty: Medium]

题目: 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 a

2016-03-23 13:48:25 4339

原创 Leet Code OJ 119. Pascal's Triangle II [Difficulty: Easy]

题目: Given an index k, return the kth row of the Pascal’s triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space?翻译: 给定一个下标k,返回第

2016-03-22 13:54:14 1250 2

原创 Leet Code OJ 118. Pascal's Triangle [Difficulty: Easy]

题目: Given numRows, generate the first numRows of Pascal’s triangle. For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]翻译: 给定一个数numRows,产生前numRows行的

2016-03-22 11:32:42 1512

原创 Leet Code OJ 8. String to Integer (atoi) [Difficulty: Easy]

题目: Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca

2016-03-22 10:43:59 10399 2

原创 Leet Code OJ 338. Counting Bits [Difficulty: Medium]

题目: Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array. Example: For num = 5

2016-03-18 18:32:33 1779

原创 Leet Code OJ 203. Remove Linked List Elements [Difficulty: Easy]

题目: 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翻译: 从一个整数链表中移除所有value为val的元素。 例如 给定

2016-03-17 23:35:10 1410

原创 Leet Code OJ 107. Binary Tree Level Order Traversal II [Difficulty: Easy]

题目: Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).For example: Given binary tree {3,9,20,#,#,15,7},

2016-03-17 20:30:17 1406

原创 Leet Code OJ 88. Merge Sorted Array [Difficulty: Easy]

题目: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold addit

2016-03-17 13:17:21 2811

原创 Leet Code OJ 110. Balanced Binary Tree [Difficulty: Easy]

题目: Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe

2016-03-16 14:02:13 1711

原创 Leet Code OJ 1. Two Sum [Difficulty: Easy]

题目: 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.Example: Given nums = [2, 7

2016-03-14 20:33:57 33042 3

原创 Leet Code OJ 191. Number of 1 Bits [Difficulty: Easy]

题目: Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11’ has binary representation 00000000

2016-03-14 15:05:14 1020

原创 一张大图总结数据结构与算法

数据结构与算法知识结构思维导图: Prim算法:浅谈最小生成树的算法思路(一)Prim算法 Kruskal算法:浅谈最小生成树的算法思路(二)Kruskal算法 快速排序:JDK的快速排序算法实现DualPivotQuicksort

2016-03-09 18:16:31 6528 1

原创 Leet Code OJ 260. Single Number III [Difficulty: Medium]

题目: Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given nums =

2016-03-09 17:50:41 880

原创 MongoDB学习笔记(四)使用Java进行实时监控与数据收集(空间使用量、连接数)

目录: MongoDB学习笔记(一)环境搭建与常用操作 MongoDB学习笔记(二)使用Java操作MongoDB MongoDB学习笔记(三)使用Spring Data操作MongoDB MongoDB学习笔记(四)实时监控与数据收集最近在做一个Java开发的监控系统,里面有一个模块是监控MongoDB的。看到网络上比较少这块资料,特记录如下: 1.下载MongoDB的J

2016-03-08 16:22:09 4982 1

原创 Leet Code OJ 102. Binary Tree Level Order Traversal [Difficulty: Easy]

题目: Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example: Given binary tree {3,9,20,#,#,15,7}, return its level order tr

2016-03-08 13:44:19 2201

原创 Leet Code OJ 26. Remove Duplicates from Sorted Array [Difficulty: Easy]

题目: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with

2016-03-08 13:19:39 1543 2

原创 Leet Code OJ 326. Power of Three [Difficulty: Easy]

题目: Given an integer, write a function to determine if it is a power of three.Follow up: Could you do it without using any loop / recursion?翻译: 给定一个整数,写一个函数去判断它是否是3的幂。 更进一步:你能不适用循环或者递归来完成吗?代码:publi

2016-03-07 16:11:32 1040

原创 Leet Code OJ 219. Contains Duplicate II [Difficulty: Easy]

题目: Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.翻译: 给

2016-03-07 14:11:58 1133

原创 Leet Code OJ 235. Lowest Common Ancestor of a Binary Search Tree [Difficulty: Easy]

题目: 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 betwee

2016-03-07 13:47:14 1121

空空如也

空空如也

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

TA关注的人

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