LeetCode (13) Pascal's Triangle (楊輝三角 ),leetcodetriangle 題目描述Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return 從第三行開始,每行除了最左邊和最右邊兩個數為1,其他數字都是上一行中相鄰兩個數字之和。根據上述規則可以寫出下面的代碼:class Solution
LeetCode (15) Flatten Binary Tree to Linked List,leetcodeflatten 題目描述Given a binary tree, flatten it to a linked list in-place.For example, Given The flattened tree should look like: 本題也是考察二叉樹和指標操作的題目。題目要求將一棵二叉樹拉平為一個鏈表
LeetCode (14) Plus One,leetcodeplus 題目描述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
URAL1965:Pear Trees(DP),ural1965pearVova was walking along one of Shenzhen streets when he noticed young pear trees, growing along the pavement. Each tree had a plaque attached to it containing some number. Vova walked around all n trees
shell 中if的使用,shellif使用shell中if做比較shell判斷數組中是否包含某個元素:ary=(1 2 3)a=2if [[ "${ary[@]}" =~ "$a" ]] ; then echo "a in ary"else echo "a not in ary"fi比較兩個字串是否相等的辦法是: if [ "$
Linux 可執行檔結構與進程結構,linux可執行檔Linux可執行檔結構在 Linux 下,程式是一個普通的可執行檔,以下列出一個二進位可執行檔的基本情況:可以看出,此可執行檔在儲存時(沒有調入到內容)分為代碼區(text)、資料區(data)和未初始化資料區(bss)3 個部分。各段基本內容說明如下:代碼區:存放 CPU
ZOJ 3471 Most Powerful(狀壓DP),zoj3471DescriptionRecently, researchers on Mars have discovered N powerful atoms. All of them are different. These atoms have some properties. When two of these atoms collide, one of them disappears and a lot of power is