原创 利用stack求柱狀圖的最大矩形面積
84. Largest Rectangle in Histogram 問題描述: Given n non-negative integers representing the histogram's bar height where
原创 Linux基礎命令之-ls
想要了解linux的文件屬性,有一個重要的也是常用的命令就必須學會使用。就是“ls”,這是一個查看文件的命令。ls是“list”的意思,重點在於顯示文件的文件名與相關屬性。。 1.ls命令集 -a:列出所有文件的名字,包括隱
原创 Pow()函數、sqrt()函數的實現
對於一些球指數冪、開方等函數經常會出現在筆試面試中。 50. Pow(x, n) 題目描述: Implement pow(x, n). Example 1: Input: 2.00000, 10 Output: 1024.00000
原创 使用動態規劃求方格路徑問題
經常遇到給定的m×n中求左上角開始起步,到達右下角的問題。這類問題可以統一用輔助數組,利用dp來解決。62. Unique Paths題目描述:A robot is located at the top-left corner of a
原创 array-3Sum
題目描述: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique tripl
原创 Linux基礎命令之-文件內容查閱
文件內容查閱的Linux命令有好些,比如cat、tac、nl、more、less、head、tail、od。 cat:由第一行開始顯示文件的內容 tac:從最後一行開始顯示文件的內容,就是cat的倒寫形式。 nl:顯示的時候,順便輸出行號
原创 Linux基礎命令之-複製、刪除與移動:cp,rm,mv
1.複製:cp cp [options] source1 source2…… directory -a:複製源文件的所有屬性和權限,相當於-pdr -d:若源文件爲連接文件的屬性(link file),則複製
原创 String類構造和方法詳解
1. 構造string string實際上是模板具體化basic_string<string>的一個typedef。它有如下的構造函數。 string類的構造函數 string(const char *s) 使用c風格字符串初始化str
原创 二分查找在array中找數
BinarySearch-33. Search in Rotated Sorted Array 問題描述: Suppose an array sorted in ascending order is rotated at some pi
原创 Math-9.Palindrome Number
題目描述: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integer
原创 全排列問題
求一個數組或者string的全排列是很經典的問題。解決此類問題,首先在自己大腦思考,通常自己求一個數組的全排列會怎麼求,比如arr[1, 2, 3],答案是:[1, 2, 3]、[1, 3, 2]、[2, 1, 3]、
原创 貪心算法的使用
貪心算法(又稱貪婪算法)是指,在對問題求解時,總是做出在當前看來是最好的選擇。也就是說,不從整體最優上加以考慮,他所做出的是在某種意義上的局部最優解。 既然貪心總是在求局部最優,所有使用貪心要首先判斷,我每次求局
原创 string-49. Group Anagrams
題目描述: Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "b
原创 string-10.Regular Expression Matching
題目描述: Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Match
原创 string-28.Implement strStr()
題目描述: Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Exampl