自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Java native关键字

        native关键字说明其修饰的方法是一个原生态方法,方法对应的实现不是在当前文件,而是在用其他语言(如C和C++)实现的文件中。Java语言本身不能对操作系统底层进行访问和操作,但是可以通过JNI接口调用其他语言来实现对底层的访问。         JNI是Java本机接口(Java Native Interface),是一个本机编程接口,它是Java软件开发工具箱(ja...

2017-08-08 10:58:00 244

原创 内存指令heppen-bebore

        Java中,synchronized和lock是用来处理并发过程中,线程之间互斥关系,即被synchronized和lock修饰的变量或方法或代码段能保证同一时间有且只有一个线程在处理,这样可以保证其它线程能够处理最新的数据,而且数据在中途不会被其它线程所修改。此外,还有一个功能就是保证数据修改的可见性。         可见性表示一个线程在修改一个数据时,对于其它线程是...

2017-08-07 12:44:51 513

原创 maven中把依赖的JAR包一起打包

转载:http://lvjun106.iteye.com/blog/1849803 这里所用到的MAVEN-PLUGIN是MAVNE-ASSEMBLY-PLUGIN官方网站是:http://maven.apache.org/plugins/maven-assembly-plugin/usage.html 1. 添加此PLUGIN到项目的POM.XML中 Xml...

2016-09-09 09:33:50 271

原创 Binary Tree Level Order Traversal——Breadth-first Search

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,null,null,15,7], 3 / \ 9 20...

2016-08-17 21:12:11 210

原创 Factorial Trailing Zeroes——Math

Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.class Solution(object): def trailingZeroes(self, n): """...

2016-08-17 21:09:48 130

原创 Climbing Stairs——Dynamic Programming

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?class Solution(object): d...

2016-08-17 20:46:49 118

原创 Ugly Number——Math

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since ...

2016-08-17 20:46:39 122

原创 Remove Duplicates from Sorted List——Linked List

Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.# ...

2016-08-17 20:44:28 122

原创 Happy Number——Math

Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares...

2016-08-15 00:14:18 151

原创 Number of 1 Bits——Bit Manipulation

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-08-15 00:13:58 121

原创 Lowest Common Ancestor of a Binary Search Tree——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 betwee...

2016-08-15 00:12:13 128

原创 Power of Three——Math

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?class Solution(object): def isPowerOfThree(self, ...

2016-08-15 00:11:01 134

原创 Power of Two

Given an integer, write a function to determine if it is a power of two.class Solution(object): def isPowerOfTwo(self, n): """ :type n: int :rtype: bool ""...

2016-08-15 00:10:27 123

原创 Python中的matplotlib画图总结

# -*- coding: utf-8 -*- import matplotlib.pyplot as plt from numpy.random import randn import numpy as np from io import StringIOimport pandas as pd '''#Create figurefig = plt.figure(...

2016-08-14 21:39:43 264

原创 Reverse Linked List——Linked List

Reverse a singly linked list.# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(obj...

2016-08-13 21:03:06 134

原创 Majority Element——Array

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 and the majority element al...

2016-08-13 21:02:08 117

原创 Excel Sheet Column Number——Math

Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ...

2016-08-13 21:01:55 144

原创 Roman to Integer——Math

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.class Solution(object): def romanToInt(self, s): """ :type s: str...

2016-08-13 21:00:15 128

原创 Valid Anagram——Hash Table

Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.class Solution(object):...

2016-08-13 20:59:48 145

原创 Same Tree——Depth-first Search

Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.# Definition ...

2016-08-12 21:42:03 162

原创 Intersection of Two Arrays——Array

Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].class Solution(object): def intersection(self, nums1, nums2):...

2016-08-12 21:40:24 135

原创 Delete Node in a Linked List——Link 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 wi...

2016-08-12 21:39:28 111

原创 Move Zeroes——Two Pointers

Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your f...

2016-08-12 21:35:15 150

原创 Invert Binary Tree——Tree

Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1 # Definition for a binary tree node.# class TreeNode(objec...

2016-08-12 21:30:53 161

原创 Maximum Depth of Binary Tree——Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. # Definition for a binary tree nod...

2016-08-11 16:27:52 102

原创 Add Digits——Math

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 di...

2016-08-11 16:26:45 122

原创 Nim Game——Brainteaser

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 th...

2016-08-11 16:24:32 152

原创 Sum of Two Integers——Bit Manipulation

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. class Solution(object): def getSum(self, a, b): ...

2016-08-11 16:23:15 92

原创 Reverse String——String

Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".class Solution(object): def reverseString(self, s): """ ...

2016-08-11 16:23:07 152

原创 Contains Duplicate II——Array

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.class ...

2016-08-10 16:24:24 106

原创 Contains Duplicate——Array

Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element ...

2016-08-10 16:19:57 93

原创 Two Sum——Array

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 = [...

2016-08-10 16:17:15 111

原创 Merge Sorted Array——Array

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 addition...

2016-08-10 16:16:48 275

原创 Remove Element——Array

Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.Th...

2016-08-10 16:15:22 119

原创 机器学习开源库(转)

1.机器学习开源软件网(收录了各种机器学习的各种编程语言学术与商业的开源软件)http://mloss.org2 偶尔找到的机器学习资源网:(也非常全,1和2基本收录了所有ML的经典开源软件了)http://www.dmoz.org/Computers/Artificial_Intelligence/Machine_Learning/Software/3 libsvm (支持...

2015-11-29 20:50:00 113

原创 JVM 字符编码转换

JVM中字符都以UTF-16的编码方式存在,即在代码中定义的所有变量和数据,在JVM中都是按照UTF-16进行编码。然而,JVM只是Java的虚拟机,所有数据最终还是要通过操作系统存储在内存中。所以,JVM和操作系统之间会进行编码转换。如果使用的是中文的Windows操作系统,那么JVM就会将字符转换成GBK的编码方式传输给操作系统进行存储。 JVM对数据的读取与写入操作分成两种类型,...

2015-11-27 10:59:17 355

原创 GB2312, GBK

GB2312与GBK 对于中文来说,通常都是用GB2312字符集或者GBK字符集。GB2312最初指的是一个编码字符集,其中包含了ASCII所包含的英文字符,同时加入了6763个简体汉字以及其他一些ASCII之外的符号。GB2312字符集同样可以使用UTF-8或者UTF-16对字符进行编码,但是一般都是用GB2312字符集自己的编码方案,即直接使用一个字符在GB2312中的编号作为存储...

2015-11-26 22:56:10 160

原创 编码字符集与字符集编码的区别

编码字符集与字符集编码     编码字符集是字符的集合,即对所有的字符进行编号,通过这个编号,就可以知道对应的字符。对于同一个字符,不同的字符集所制定的整数编号也不尽相同,例如“儿”这个字,在Unicode中,它的编号是0x513F,而在另一种编码字符集比如Big5中,这个字就是第0xA449个字符了。    字符集编码是如何将字符集中的一个字符的整数编号对应到一个计算机认识的二进...

2015-11-26 22:42:30 148

原创 vim显示行号、语法高亮、自动缩进的设置

在UBUNTU中vim的配置文件存放在/etc/vim目录中,配置文件名为vimrc 在Fedora中vim的配置文件存放在/etc目录中,配置文件名为vimrc在Red Hat Linux 中vim的配置文件存放在/etc目录中,配置文件名为vimrcset nocompatible                 "去掉有关vi一致性模式,避免以前版本的bug和局限    ...

2014-09-21 11:04:57 163

原创 文本比较算法——LD算法

       在日常应用中,文本比较是一个比较常见的问题。文本比较算法也是一个老生常谈的话题。  文本比较的核心就是比较两个给定的文本(可以是字节流等)之间的差异。目前,主流的比较文本之间的差异主要有两大类。一类是基于编辑距离 (Edit Distance)的,例如LD算法。一类是基于最长公共子串的(Longest Common Subsequence),例如Needleman/Wunsc...

2014-09-17 14:54:10 621

空空如也

空空如也

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

TA关注的人

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