自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 leetcode Trapping Rain Water

class Solution(object): def trap(self, height): """ :type height: List[int] :rtype: int """ height = [0] + height + [0] r = 0 begin =0

2015-10-28 12:46:46 276

原创 leetcode Path Sum II

# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): d

2015-10-20 15:33:23 346

原创 leetcode Path Sum

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ clas

2015-10-18 21:15:44 227

原创 leetcode Merge Two Sorted Lists

class Solution { public: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) { if (l1==NULL) return l2; if (l2==NULL) return l1; ListNode* temp; // Assume l1 < l2

2015-10-17 13:13:19 266

原创 leetcode 3sum

class Solution(object): def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ results = [] target_pre = None nums.

2015-10-17 12:25:15 242

原创 模拟Poisson过程

输入参数: λ\lambda la, 事件数Nimport numpy as np import pylab xs = [random.expovariate(la) for i in range(N)] ps = np.cumsum(xs) pylab.plot(ps,len(xs)*[1],'-o')

2015-05-21 21:43:36 7727

原创 leetcode JumpGame

class Solution { public: bool canJump(vector& nums) { int far = 0; int index=0; int f=0; for (auto it = nums.begin();it<nums.end();it++) { index

2015-05-01 16:48:22 313

原创 leetcode Combinations

非递归: class Solution { public: vector> combine(int n, int k) { vector states; vector> results; for (int i=0;i<k;i++) states.push_back(i+1); auto cur_pos = states.en

2015-05-01 16:08:27 357

原创 leetcode Search Insert Position

class Solution { public: int searchInsert(vector& nums, int target) { if (nums.size()==0) return 1; int l=0; int h=nums.size()-1; int mid; while (l<=h){

2015-05-01 14:02:47 223

原创 leetcode Search for a Range

class Solution { public: vector<int> searchRange(vector<int>& nums, int target) { int l1=0; int l2=0; int rl=-1; int rr=-1; int h1=nums.size()-1; int

2015-05-01 13:33:36 326

原创 leetcode Longest Valid Parentheses

#include <vector> class Solution { public: int longestValidParentheses(string s) { int r = 0; int r_max=0; int pl= 0; vector<int> app; for(auto i=s.begin();i

2015-05-01 00:21:38 204

原创 leetcode Search in Rotated Sorted Array

class Solution { public: int search(vector<int>& nums, int target) { if (nums.size()==0) return -1; if (nums.size()==1) return (nums[0]==target)-1; int p = findPivot(nums);

2015-04-30 23:09:18 233

原创 leetcode Median of Two Sorted Arrays

double inline mynext(int A[], int m, int a, int B[], int n, int b){ if (a >= m) return B[b]; if (b >= n) return A[a]; return A[a] < B[b] ? A[a] : B[b]; } class Solution { public: d

2015-04-30 21:32:12 362

原创 leetcode Reverse Nodes in k-Group

# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param head, a ListNode # @param k, an

2015-04-30 21:31:05 231

原创 leetcode Remove Duplicates from Sorted Array

class Solution { public: int removeDuplicates(int A[], int n) { if (n<2) return n; int delta=0; int i=1; while(i<n){ if (A[i]==A[i-1]) delta++;

2015-04-30 21:29:33 284

原创 leetcode Next Permutation

#include class Solution { public: void nextPermutation(vector &num) { int n = num.size()-1; for (auto i=num.end()-2;i>=num.begin();i--){ if ((*i)>=(*(i+1))) continue;

2015-04-30 21:27:40 210

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除