原创 18.leetcode題目28: Implement strStr()

題目: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part

原创 19.leetcode題目303: Range Sum Query - Immutable

題目: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: G

原创 16.leetcode題目228: Summary Ranges

題目: Given a sorted integer array without duplicates, return the summary o

原创 21.leetcode題目234: Palindrome Linked List(第2種方法是鏈表翻轉,等做完206題再做!)

題目: Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) sp

原创 17.leetcode題目204: Count Primes(不是最快的!)

前言:這道題目一開始覺得挺簡單的,編寫一個判斷每一個數是否是質數的函數isPrime:</pre><pre name="code" class="c

原创 4.線程和進程

關於進程和線程描述正確的是() 正確答案: A B D   你的答案: A B C D (錯誤) 線程不擁有系統資源,但可以訪問隸屬於進程的資源 在創建或銷燬進程時,系統開銷明顯大於創建或銷燬線程時開銷 進程是

原创 20.leetcode題目67: Add Binary

題目: Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 分

原创 3.Linux中fork()函數

     一個進程,包括代碼、數據和分配給進程的資源。fork()函數通過系統調用創建一個與原來進程(父進程)幾乎完全相同的進程(子進程),這兩個進程共享代碼空間,但數據空間是獨立的,子進程數據空間中的內容是父進程的完整拷貝,指令指針也完

原创 28.leetcode題目292: Nim Game

題目: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of

原创 2.堆和棧

注::基本是網上查找的答案 heap堆:是由malloc和new之類函數分配的空間所在地,由程序員分配和釋放,若程序員不釋放,程序結束時可能由os回收。地址是由低向高增長的。heap的空間是很大的自由區。  stack棧:是自動分配變量

原创 24.leetcode題目20: Valid Parentheses

前言:這道題目在《數據結構》這本書上有講,學習真的很重要啊! 題目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', det

原创 25.leetcode題目190: Reverse Bits(Follow up未解決)

題目: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00

原创 1.學習1: 埃拉托色尼篩選法(求一定範圍內的質數)

前言:這是在刷leetcode第204題: Count Primes時hint提示的。 埃拉托色尼選篩法(the Sieve of Eratosthenes)簡稱埃氏篩法,是古希臘數學家埃拉托色尼(Eratosthenes 274B.

原创 23.leetcode題目203: Remove Linked List Elements(待再做)

題目: Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4

原创 30.leetcode題目104: Maximum Depth of Binary Tree(遞歸,深度優先)

題目: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path fro