我的技术我做主......
QU66Q · 共 73 篇文章
Java native关键字
native 关键字说明其修饰的方法是一个原生态方法,方法对应的实现不是在当前文件,而是在用其他语言(如C和C++)实现的文件中。Java语言本身不能对操作系统底层进行访问和操作,但是可以通过 JNI 接口调用其他语言来实现对底层的访问。 JNI是Java本机接口(Java Native Interface),是一个本机编程接口,它是Java软件开发工具箱(java Software Development Kit,SDK)的一部分。JNI允许Java代码使用以其他语言编写的代码和代码库。Invocation API(JNI的一部分)可以用来将Java虚拟机(JVM)嵌入到本机应用程序中,从…
2017-08-08 10:58 · JAVA · 评论(0)
内存指令heppen-bebore
Java中,synchronized和lock是用来处理并发过程中,线程之间互斥关系,即被synchronized和lock修饰的变量或方法或代码段能保证同一时间有且只有一个线程在处理,这样可以保证其它线程能够处理最新的数据,而且数据在中途不会被其它线程所修改。此外,还有一个功能就是保证数据修改的可见性。 可见性表示一个线程在修改一个数据时,对于其它线程是可见的,即其它线程是会知道这个数据在被修改了,从而会等数据修改完后再取值,保证取到的值是最新的。 首先,要了解一下内存。目前内存包括缓存和内存,由于CPU的计算速度快于读取内存数据的速度,所以为了缩短读写时间,在原有的内存的基础上,又加了缓…
2017-08-07 12:44 · JAVA · 评论(0)
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代码 <buizld> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <…
2016-09-09 09:33 · JAVA · 评论(0)
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 / \ 15 7 return its level order traversal as: [ [3], [9,20], [15,7] ] # Definition for a binary tree node. # clas…
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): """ :type n: int :rtype: int """ result = 0 t = 5 while t <= n: result += n/t t *= 5 return result
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): def climbStairs(self, n): """ :type n: int :rtype: int """ w = [0]*n if n == 0: return 0 if n == 1: return 1 …
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 it includes another prime factor 7 . Note that 1 is typically treated as an ugly number. class Soluti…
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 . # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None cla…
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 of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops end…
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 00000000000000000000000000001011 , so the function should return 3. class Solution(object): def hammingWeight…
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 between two nodes v and w as the lowest node in T that has both v and w as descendants (where we allow a no…
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, n): """ :type n: int :rtype: bool """ #method 1 return n > 0 and 3 ** round(math.log(n,3)) == n #method 2 if n <…
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 """ return True if not n&(n-1) and n != 0 else False
Python中的matplotlib画图总结
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt from numpy.random import randn import numpy as np from io import StringIO import pandas as pd ''' #Create figure fig = plt.figure() #创建子图subplot: 表示2X2,即4个子图中的第1个图,编号为1 #参数:nrows, ncols, sharex(所有子图是否使用相同的x轴),sharey,subplot_kw(用于创建各subplot的关键字…
2016-08-14 21:39 · Python · 评论(0)
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 = None class Solution(object): def reverseList(self, head): """ :type head: ListNode :rtype: ListNode """ if head is None or head.next is None: return hea…