標籤:MyDate類public class MyDate{ private int year, month, day; private static int thisYear=2015; public MyDate(int year, int month, int day){ this.year=year; this.month=month; this.day = day; } public MyDate(){ this(1970,1,1
標籤:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of
標籤:1,採用選擇排序對元素進行排列時,元素之間需要進行比較,因此需要實現Comparable<T>介面。即,<T extends Comparable<T>>. 更進一步,如果允許待比較的類型可以和它的父類型進行比較,則需要寫成:<T extends Comparable<? super T>, 其中<? super T> 表示 T 的任意超類。2,SelectionSortArray.java
標籤:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.解題思路:使用DFS演算法,JAVA實現如下: static String[] alpha = new String[] { "
標籤:唯一出現一次的三個數首先在leetcode上面有這樣類似的題,做法大致類似1,首先是只出現一次的一個數比較簡單,直接全部亦或值就得到了//只出現一次的一個數 public static int singleNumber1(int[] A) { int res=0; for(int i=0;i<A.length;i++) res^=A[i]; return res;
標籤:問題:聲明複數類,成員變數包括實部和虛部,成員方法包括實現由字串構造複數、複數加法、減法、字串描述、比較相等等操作。聲明複數類如下public class Complex { public double real,imag; //實部,虛部 public Complex(double real, double imag) //構造方法 public Complex(double real)