原创 在eclipse中安裝m2eclipse

m2eclipse是一款Eclipse下十分強大的Maven插件,在啓動eclipse之後,在菜單欄中選擇help->install new software...在彈出來的對話框中在work with字段中輸入 地址:http://do

原创 LeetCode Add Two Numbers

<pre name="code" class="cpp"> class Solution { public: ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {

原创 類擴展

之前在看代碼的時候一直不明白在.m文件中爲什麼有@interface,爲什麼要在.m文件中寫@property,而不是寫在.h文件中,今天重新讀《Objective -C基礎教程》,才發現這種寫法是類擴展(class extention)

原创 LeetCode Two Sum

class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int>ans,tmp; tm

原创 ex1 Gradient Descent

Gradient descent 不知道怎麼把公式放上來 下面是我的代碼。function [theta, J_history] = gradientDescent(X, y, theta, alpha, num_iters) %GRAD

原创 LeetCode Maximum Depth of Binary Tree

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *

原创 LeetCode Power of Two

Given an integer, write a function to determine if it is a power of two. 若一個數字是2的冪,那麼它的二進制表示形式裏面只有一個1,那麼n-1剛好是除了爲1的那位之外

原创 LeetCode Move Zeroes

class Solution { public: void moveZeroes(vector<int>& nums) { int i=0; int cnt=0; while(i<n

原创 Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to

原创 @property總結

參考網址: http://blog.csdn.net/dfqin/article/details/11669993 http://www.linuxidc.com/Linux/2014-03/97744.htm http://www.c

原创 LeetCode Longest Common Prefix

class Solution { public: string longestCommonPrefix(vector<string>& strs) { if (strs.size()==0) {

原创 Leetcode Number of Digit One

Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.

原创 LeetCode Binary Tree Right Side View

層次遍歷 我的想法:層序遍歷,然後輸出每一層最右邊的節點代碼如下: class Solution { public: vector<int> rightSideView(TreeNode* root) { vect

原创 C語言中如何解決重複include的問題

採用#ifndef 格式如下: #ifndef __SOMEFILE _H_ #define __SOMEFILE _H_ ...//一些聲明語句 #endif         #ifdndef的方式依賴於宏名不允許衝突。這不光可以保證同

原创 Leetcode House Robber

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed,