原创 268. Missing Number#1(Done)

Solution#2 public class Solution { public int missingNumber(int[] nums) { int i = 0; int result

原创 122. Best Time to Buy and Sell Stock II

題目摘要 給定一個數組,第i個元素代表第i天的股票價格。 你可以隨意交易,但是買進之前必須先賣出,求出最大利潤 解法 1. 如果第i個元素大於第i - 1個元素,將差價加到總利潤上 注意 可問問題 原題 Say you have

原创 閱讀幫助

概念 函數 zend_parse_parameters 功能: 獲取函數調用者傳遞過來的參數 參數: ZEND_NUM_ARGS() TSRMLS_CC:用戶實際傳遞到函數的參數數量。此數值做爲 ht 參數傳給函數,應使用做爲

原创 195. Tenth Line#1

題目摘要 答應文件第10行 解法 1. 2. 注意 1. 如果文件沒有10行,輸出什麼? 可問問題 原題 How would you print just the 10th line of a file? For examp

原创 35. Search Insert Position

題目摘要 給定一個有序數組和一個目標值,從數組裏面找出目標值的位置。如果找不到,返回它插入的位置。 解法 1. 查找先想到二分法,此處需要改良二分查找法。 2. 具體思想爲二分,如果目標值在區間外,或者找到目標值,則可以確定目標位置

原创 empty

函數說明 實際執行的是源碼中的 i_zend_is_true 函數 /** * 使用一個字符串分割另一個字符串 * @param mixed $val 變量或表達式 * @return bool */ empty ( $val

原创 explode

函數說明 /** * 使用一個字符串分割另一個字符串 * @param string $delimiter * 邊界上的分隔字符 * @param string $string * 輸入的字符串 * @param int $

原创 180. Consecutive Numbers(Done)

題目摘要 寫一個SQL查詢,用來尋找所有連續出現三次以上的Num Id Num 1 1 2 1 3 1 4 2 5 1 6 2 7 2 例如,給定如上Logs表,返回1 解法 # Write

原创 193. Valid Phone Numbers#1

題目摘要 從文件裏篩選出電話號碼,電話號碼有兩種格式 (xxx) xxx-xxxx 和 xxx-xxx-xxxx。假設每行頭尾都沒有空格。 解法 注意 可問問題 原題 Given a text file file.txt that c

原创 476. Number Complement#2

Solution#1 public class Solution { public int findComplement(int num) { int tmp = num; int count =

原创 數據類型轉換

數據類型轉換 轉換爲 boolean false: false, 0, 0.0, "", "0", 空數組, 空對象, NULL, 未賦值變量 true: 其他 轉換爲integer(32位最大值約爲20億) 從 boolean

原创 184. Department Highest Salary#1

題目摘要 選出每棟Department中薪水最高的人(每棟樓不知一個) 解法 Solution1 # Write your MySQL query statement below SELECT d.Name AS Department

原创 191. Number of 1 Bits#1(Done)

Solution#1(2ms) public class Solution { // you need to treat n as an unsigned value public int hammingWeight(in

原创 122. Best Time to Buy and Sell Stock II(Done)

Solution#1 public class Solution { public int maxProfit(int[] prices) { if (prices == null || prices.length

原创 541. Reverse String II#1

Solution public class Solution { public String reverseStr(String s, int k) { if (s == null || s.length() ==