原创 歡迎使用CSDN-markdown編輯器

歡迎使用Markdown編輯器寫博客 本Markdown編輯器使用StackEdit修改而來,用它寫博客,將會帶來全新的體驗哦: Markdown和擴展Markdown簡潔的語法 代碼塊高亮 圖片鏈接和圖片上傳 LaTex數學公

原创 LeetCode Algorithms 32. Longest Valid Parentheses 題解

題目:求最長的匹配括號子串長度 匹配括號,使用棧是最好的。push左括號,遇到右括號就把最上面的左括號pop出來,每pop一個左括號就是一次匹配。 那麼現在問題就是怎麼確定子串的長度,先考慮特殊情況,如果進行push,pop之後棧是空的,

原创 LeetCode Algorithms 5. Longest Palindromic Substring 題解

題目: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1

原创 黑板客爬蟲闖關

這個爬蟲闖關挺適合入門的,主要是爬取靜態網頁以及模擬登陸。 一共有5關,重點講第4關和第5關。 1-3關 第1關是每個頁面都帶有一串數字,然後要把這串數字替換到url上再訪問,從而進入下一個地址獲取下一串數字,直至過關。對於瞭解ht

原创 LeetCode Algorithms 18. 4Sum 題解

題目: 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

原创 LeetCode Algorithms 76. Minimum Window Substring 題解

題目: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in com

原创 LeetCode Algorithms 78. Subsets 題解

題目:給定一個集合,返回其所有子集。 求一個集合的powset,共有2^n個子集,只要判斷每個元素是否在子集裏,每個元素有兩種可能,存在在或不存在,因此共有2^n個子集。 結合這個思想,我們可以這樣得到子集:遍歷到新的元素e時,都存在子集

原创 LeetCode Algorithms 279. Perfect Squares 題解

題目 Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which

原创 算法概論 課後習題 8.3 證明

EX 8.3 STINGY SAT is the following problem: given a set of clauses (each a disjunction of literals) and an integer k,

原创 LeetCode Algorithms 226. Invert Binary Tree 題解

題目:反轉二叉樹 Trivia: This problem was inspired by this original tweet by Max Howell: Google: 90% of our engineers use

原创 LeetCode Algorithms 98. Validate Binary Search Tree 題解

題目:判斷一棵樹是否爲BST樹 因爲BST廣爲人知,所以就不搬原文了,其中節點的數值是int類型。 對於BST樹,對它做中序遍歷即可輸出排好序的一串數字,那麼對於這個題目就有兩個思路: 1. 對這棵樹做一次中序遍歷,輸出一個數組,然後

原创 LeetCode Algorithms 7. Reverse Integer 題解

題目: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 對輸入的整數進行翻轉,保留符號,與之

原创 LeetCode Algorithms 50. Pow(x, n) 題解

題目: Implement pow(x, n). 沒有特殊要求,根據題目要求的輸入,是(double x, int n),那麼最大的階數是MAX_INT,最小的階數是MIN_INT。 首先想到的是,一個while循環,res*=

原创 LeetCode Algorithms 8. String to Integer (atoi) 題解

題目 Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you wan

原创 LeetCode Algorithms 3. Longest Substring Without Repeating Characters 題解

題目: Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcb