原创 【Leetcode】Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the
原创 堆和棧的區別
一、預備知識—程序的內存分配 一個由C/C++編譯的程序佔用的內存分爲以下幾個部分 1、棧區(stack)— 由編譯器自動分配釋放 ,存放函數的參數值,局部變量的值等。其 操作方式類似於數據結構中的棧。 2、堆區(heap) —
原创 【Leetcode】Search in Rotated Sorted Array
在旋轉的無重複的排序數組中查找某個數,要求時間複雜度O(logN) Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1
原创 【Leetcode】Search in Rotated Sorted Array II
從一個旋轉的排序數組中尋找一個數字,數組中可能有重複數字,要求時間複雜度O(LogN)。 ( 1 1 1 2 4 might become 1 1 2 4 1). You are given a target value to sea
原创 【Leetcode】Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place. For example, Gi
原创 【Leetcode】Unique Binary Search Trees
假設給定n個節點,節點值爲1,2,3...,n,求由這些結點可以構成多少棵不同的二叉查找樹。 Given n, how many structurally unique BST's (binary search trees) that s
原创 【Leetcode】Set Matrix Zeroes
給定一個m x n的矩陣,如果某個元素爲0,則把該元素所在行和列全部置0。 Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do
原创 【Leetcode】Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake. Recover
原创 【Leetcode】Triangle
給定一個由數字組成的三角形,從頂至底找出路徑最小和。 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to ad
原创 陰影錐(Shadow Volume)
Shadow Map和Shadow Volume是當今比較流行的實時陰影渲染方法,跟Shadow Map相比,Shadow Volume最大的優點是沒有陰影鋸齒問題,但由於它是基於幾何的方法,每幀都有可能要構造和渲染陰影錐,而且有些工作必
原创 OpenGL中的拾取(Picking)
OpenGL本身支持基於圖像空間的拾取,這裏指的是幾何拾取,即由屏幕點擊觸發一條射線,然後和場景中的物體求交,進而判斷是否拾取到物體。現在先把OpenGL的投影矩陣和視口變換矩陣列出來: OpenGL的投影矩陣: OpenGL的視口變換
原创 OpenGL渲染管線
OpenGL Rendering Pipeline框圖,分爲頂點變換,圖元裝配和光柵化,像素着色以及像素運算四個階段。 1、頂點變換 這個階段的輸入是頂點集以及頂點的屬性信息,在個階段完成這些操作:(1) 對頂點進行變換;(2)逐頂點光
原创 【Leetcod】Unique Binary Search Trees II
給定結點數n,結點值爲1,2,...,n,求由這些結點可以構成的所有二叉查找樹。 Given n, generate all structurally unique BST's (binary search trees) that st
原创 Linux架構
作者:Vamei 出處:http://www.cnblogs.com/vamei 歡迎轉載,也請保留這段聲明。謝謝! 我們以下圖爲基礎,說明Linux的架構(architecture)。(該圖參考《Advanced Programm
原创 c++模板特化
一、模板特化, specialization of template 模板特化(specialization of template)並不是說實例化一個模板,如template <class T>,class stack<T>;聲明s