原创 LeetCode 51. N-Queens 回溯

51. N-Queens The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens a

原创 LeetCode 131. Palindrome Partitioning 樹形問題,狀態回溯

131. Palindrome Partitioning Given a string s, partition s such that every substring of the partition is a palindr

原创 LeetCode 279. Perfect Squares 轉換思維圖的無權BFS,尋最短路徑

Perfect Squares 題意 注意 思路 代碼 題外memset的使用 279. Perfect Squares Given a positive integer n, find the least

原创 LeetCode 17. Letter Combinations of a Phone Number 遞歸回溯法

17. Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations that the n

原创 LeetCode 523. Continuous Subarray sum和 525. Contiguous Array和560. Subarray Sum Equals K

leetcode題解 以下三題解法非常類似 總結:523. Continuous Subarray Sum 求最長連續子序列的和是k的倍數 525. Contiguous Array 求最長連

原创 深信服面試記錄 2017

電話面了接近40分鐘,對於自己簡歷上寫的東西一定要清清楚楚明明白白,切勿模棱兩可!!! 1.線程的通信方式。A線程擁有互斥變量,B線程需要這個互斥變量,當A線程意外退出,B線程能否獲取這個互斥變量? 2.MFC中創建線程的流

原创 2018屆美團筆試 k的倍數 改考卷。搜狗圓周上點的距離。

題一 k的倍數 思路 k的倍數且求的是最長連續子序列。 更改523. Continuous Subarray Sum思路2即可 每次計算得到的餘數,若不在hash表中,就插入到hash表中,若餘數已經在hash表中

原创 2018京東筆試 瘋狂序列 神奇數

瘋狂序列 輸入:169 輸出:18 #include <iostream> #include <math.h> using namespace std; int main() { long long n;

原创 Effective C++ 知識點記錄

導讀 聲明式,定義式,初始化 explict關鍵字,類的構造函數聲明爲explict,可以阻止它們被用來執行隱式類型轉換。 除非有一個好理由允許構造函數被用於隱式類型轉換,否則聲明爲explict。 pass-by-va

原创 二叉堆,堆排序,STL優先隊列的底層實現,劍指offer數據流中的中位數

一. 下圖是從數組爲0下標開始計算的。 下圖是從數組爲1下標開始計算的。引自《STL源碼剖析》 p173 堆排序 64.數據流中的中位數。《劍指offer》 p286 如何得到一個數據流中的中位數?如果從

原创 數據共享,內存映射文件和虛擬內存,共享內存

一、內存映射 內存映射文件允許開發人員預定一塊地址空間區域並給區域調撥物理存儲器。內存映射文件的物理存儲器來自磁盤已有的文件,而不是來自系統的頁交換文件。一旦把文件映射到地址空間,就可以對它進行訪問,就好像整個文件都已經被載入內

原创 LeetCode 226. Invert Binary Tree 遞歸、指針交換 思考鏈表的交換

226. Invert Binary Tree Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4

原创 LeetCode 235. Lowest Common Ancestor of a Binary Search Tree 二叉搜索樹

235. Lowest Common Ancestor of a Binary Search Tree Given a binary search tree (BST), find the lowest common ances

原创 LeetCode 437. Path Sum III 遞歸中使用遞歸,分兩類情況

437. Path Sum III You are given a binary tree in which each node contains an integer value. Find the number of pat

原创 LeetCode 257. Binary Tree Paths 遞歸過程保存信息

257. Binary Tree Paths Given a binary tree, return all root-to-leaf paths. For example, given the following binary