标签:amp blog pre return ++ log rem class bst
数组:
1 public: 2 /** 3 * @param A: a list of integers 4 * @return : return an integer 5 */ 6 int removeDuplicates(vector<int> &nums) { 7 // write your code here 8 int n=nums.size();int j; 9 for(int i=0;i<n-1;i++){ 10 for( j=1;j<n;j++){ 11 if(nums[i]==nums[j]){ 12 nums[j+1]=nums[i]; 13 } 14 } 15 } 16 nums.resize(j); 17 return j; 18 };
买卖股票:
1 public: 2 /** 3 * @param A: a list of integers 4 * @return : return an integer 5 */ 6 int removeDuplicates(vector<int> &nums) { 7 // write your code here 8 int n=nums.size();int j; 9 for(int i=0;i<n-1;i++){ 10 for( j=1;j<n;j++){ 11 if(nums[i]==nums[j]){ 12 nums[j+1]=nums[i]; 13 } 14 } 15 } 16 nums.resize(j); 17 return j; 18 };
1 class Solution { 2 public: 3 /** 4 * @param n: An integer 5 * @return: An integer 6 */ 7 int climbStairs(int n) { 8 // write your code here 9 if(n == 0) return 1; 10 if(n <= 2) return n; 11 int b1,b2,b3; 12 b1 = 1; 13 b2 = 2; 14 for(int i = 2; i < n; ++i) 15 { 16 b3 = b1 + b2; 17 b1 = b2; 18 b2 = b3; 19 } 20 return b3; 21 22 } 23 };
标签:amp blog pre return ++ log rem class bst
原文地址:http://www.cnblogs.com/wxn-151/p/6523153.html