標籤:HADOOP運行mr程式時報錯:15/05/18 19:25:33 INFO mapred.ClientServiceDelegate: Application state is completed. FinalApplicationStatus=SUCCEEDED. Redirecting to job history server15/05/18 19:25:34 INFO ipc.Client: Retrying connect to server: nwj5/192.168.11.
標籤:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.解題思路:用兩個boolean數組row col表示行列是否有零即可,JAVA實現如下:public void setZeroes(int[][] matrix) {if (matrix.length == 0 || matrix[0].length == 0)return;boolean[] row =
標籤:JAVA的LIST在刪除時,一般會用list.remove(o); 但這樣往往會出現問題,先來看下面的這段代碼:package com.demo;import java.util.ArrayList;import java.util.List;public class Test11 {public void delete(){List<Integer> list = new
標籤:Composite定義:將對象以樹形結構組織起來,以達成“部分-整體” 的階層,使得用戶端對單個對象和組合對象的使用具有一致性。Composite比較容易理解,想到Composite就應該想到樹形結構圖。組合體內這些對象都有共同介面,當組合體一個對象的方法被調用執行時,Composite將遍曆(Iterator)整個樹形結構,尋找同樣包含這個方法的對象並實現調用執行。可以用牽一動百來形容。所以Composite模式使用到Iterator模式,和Chain of
標籤:Implement int sqrt(int x).Compute and return the square root of x.解題思路一: public int mySqrt(int x) { return (int)Math.sqrt(x); } 神奇般的Accepted。解題思路二:參考平方根計算方法 計算平方根的演算法這裡給出最簡單的牛頓法,JAVA實現如下: public int mySqrt(int x) {
標籤: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?解題思路:遞迴會導致逾時,用動態規劃即可,JAVA實現如下; public int climbStairs(int n) { if(n==1)