位运算的一些总结 Java提供的位运算符有:左移( 、右移( >> ) 、无符号右移( >>> ) 、位与( & ) 、位或( | )、位非( ~ )、位异或( ^ ),除了位非( ~ )是一元操作符外,其它的都是二元操作符。1、左移( Test1、将5左移2位:public class Test { public static void main(String[] args) {
java Thread 学习 一、Thread and Runnable之前说过 Thread 的两种实现方式,一种是继承Thread类,一种是实现Runnable接口。 两种实现方式的异同如下: 其实就是Class 和 Interface 之间的不同。Runnable 为一个接口,由于接口的多实现性,使其更具可扩展性,而且有利于资源的共享。比如,一个实现了Runnable接口的对象可以创建多个线程,使他们可以
leetcode MergeTwoSortedList /** * * 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. * */key Notethe solution is sam
leetcode remove duplicate of sorted list /** * Given a sorted linked list, delete all duplicates such that each element appear only once. * */很简单,没有啥可说的public void removeDuplicates(ListNode node){ListNode cur = node;while(cur!=
求该整数的二进制表达中有多少个1 题目:输入一个整数,求该整数的二进制表达中有多少个1。例如输入10,由于其二进制表示为1010,有两个1,因此输出2。分析:这是一道很基本的考查位运算的面试题。包括微软在内的很多公司都曾采用过这道题。一个很基本的想法是,我们先判断整数的最右边一位是不是1。接着把整数右移一位,原来处于右边第二位的数字现在被移到第一位了,再判断是不是1。这样每次移动一位,直到这个整数变成0为止。现在的
java.util List and set List and Set are two interfaces which extends from the interface Collection.1.ListList接口提供的适合于自身的常用方法均与索引有关,这是因为List集合为列表类型,以线性方式存储对象,可以通过对象的索引操作对象。List接口的常用实现类有ArrayList和LinkedList,在使用Lis
java.util Iterable and Iterator Iterable and Iterator两个接口, 很简单。/*** Iterable is an interface allows an objefct to be the target of the * "foreach" statement**/public interface Iterable{ //return an iterator over a set of
顶住!!! 不知道如何形容此时的心情,迷茫、失落、期待、担心、愧疚、不舍、孤单、烦躁、沉重,却又是那么的麻木。因为这些情绪我都可以承担,就像没有任何情绪。就像,必须,一个人承担起生命的重量。I can handle this, I can take this
The implement of Binary Search Tree (JAVA) An implement of Binary Search Tree in JAVAFunctionsCreate Insert Delete Find Min Max Display Search Traver
PlusOne /** * Given a non-negative number represented as an array of digits, plus one to * the number. * * The digits are stored such that the most significant digit is at the head of * the list.
连续最大和自数组 题目:/** * Find the contiguous subarray within an array (containing at least one number) * which has the largest sum. For example, given the array [-2, 1, -3, 4, -1, * 2,1, -5, 4 ], the contiguo
leetcode 之 二进制数相加 /** * Given two binary strings, return their sum (also a binary string). * * For example, a = "11" b = "1" Return "100". * * 题目翻译: * * 给定两个二进制字符串,返回它们的和(也是一个二进制字符串)。 例如, a = "11" b =
leetcode 之 length of last word. 题目/** * * 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, ret
单向链表的简单实现 java单向链表的简单实现。关于单向链表Advantages· Linked lists are a dynamic data structure, allocating the needed memory while the program is running.· Insertion and deletion node operations ar
单向链表的java简单实现 一种单向链表的简单实现java关于单向链表单向链表的数据结构可以分为两部分:数据域和指针域,数据域存储数据,指针域指向下一个储存节点的地址。Advantages· Linked lists are a dynamic data structure, allocating the needed memory while the program is
leetCode 之SearchInsertPosition 题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.其实就是查找的扩展两种, 递归和迭代 // 递归 pub
leetCode 之 两个二进制数相加 题目: * Given two binary strings, return their sum (also a binary string). * * For example, a = "11" b = "1" Return "100". * * 题目翻译: * * 给定两个二进制字符串,返回它们的和(也是一个二进制字符串)。 例如, a = "11" b =