原创 golang切片及變參傳值 指針
**** 理解切片 ptr指向了一塊內存區域 大小是cap 實際存放的內容大小是len 每次執行切片後相當於存放了一個指向該位置的索引結構 故修改值會相互影響 是一種引用 在創建數組時沒有指定大小即是創建切片 。或者聲明瞭一個數組後
原创 goLang閉包理解
閉包是爲了在函數內部捕獲外部變量(不聲明爲全局變量) 例如實現一個計數器 從base開始 每調用一個加一 在c++ 中可以採用仿函數,在調用構造函數時傳入base 或者使用lambda函數,捕獲base變量 class fun{ pri
原创 c++11 unkown總結
static_cast 類似於c中強制轉型 也能把父類型強制轉爲子類型(不安全 指針不能訪問子類型中的函數)在編譯時檢查 dynamic_cast 在運行時會檢查 如果轉換不合理 對於指針類型會返回NULL class T{ publ
原创 c++ const關鍵字總結 以及valgrind使用
常對象只能訪問常成員函數(訪問非常成員函數肯能會改變自己的值) 使用g++ 編譯test.c 加上-g選項 在使用valgrind是就能定位到源代碼中的位置 valgrind --tool=memcheck --leak-check=
原创 go基礎
變量定義 1. 聲明類型 不賦初值 (採用默認值 eg: sring "" int 0) var name bool 2. 賦值 a := 15 同時定義多個變量 var(a int; b bool) a, b:= 20,
原创 typename和class一點點區別
使用typename T::bartype bar 表示使用這一類型 namespace test{ /* traits 是爲了獲取迭代器指向值的類型 在迭代器中放入value_type * traits 是一個只
原创 Count Numbers with Unique Digits(排列組合)
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Input: 2 Output:
原创 Palindrome Pairs (暴力匹配不如查找)
Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of
原创 Max Sum of Rectangle No Larger Than K(二維矩陣求最小子矩陣和 以及小於等於k的LIS)
Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is
原创 Reconstruct Itinerary(求歐拉路徑)
Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itin
原创 Maximum Product of Word Lengths
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not shar
原创 Integer Break
Given a positive integer n, break it into the sum of at leasttwo positive integers and maximize the product of those in
原创 range module
A Range Module is a module that tracks ranges of numbers. Your task is to design and implement the following interfaces
原创 二分查找總結
數組值唯一 : 正常的二分查找 數組值不唯一: lower_bound() 返回第一個>=val的位置 這個就是在右邊界等於val時也要縮短右邊界 int find(vector<int> &arr, int val){ int
原创 Russian Doll Envelopes 以及LIS 二分查找解法
You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into an