自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

leetcodecl

leetcode刷题进步

  • 博客(10)
  • 收藏
  • 关注

原创 【回溯/二叉树】113. Path Sum II

class Solution {public: vector<vector<int>> pathSum(TreeNode* root, int sum) { vector<vector<int>> ans; vector<int> temp; if(root==NULL) ...

2018-06-29 18:29:41 139

原创 【Array】73. Set Matrix Zeroes

class Solution {public: void setZeroes(vector<vector<int>>& matrix) { if(matrix.size()==0) return; int flag=0; for(int i=0;i<matrix.size();i++) { ...

2018-06-28 23:17:11 98

原创 【二叉树】129. Sum Root to Leaf Numbers

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

2018-06-28 21:10:06 91

原创 【二叉树】108. Convert Sorted Array to Binary Search Tree

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

2018-06-28 20:45:02 79

原创 523. Continuous Subarray Sum

顺序扫描数组,并存储每一个位置的sum与k的余数,当余数重复出现时,即产生解;class Solution {public: bool checkSubarraySum(vector<int>& nums, int k) { unordered_map<int,int> table; int sum=0; in...

2018-06-26 20:27:31 73

原创 【回溯】22. Generate Parentheses

class Solution {public: vector<string> generateParenthesis(int n) { int left=0,right=0; vector<string> ans; string temp; generate(ans,temp,left,right,n); re...

2018-06-22 10:32:29 105

原创 12. Integer to Roman

class Solution {public: string intToRoman(int num) { int nums[4]={1000,100,10,1}; char big[4]={'M','C','X','I'}; char small[4]={' ','D','L','V'}; string ans; for(int...

2018-06-21 22:50:37 67

原创 3. Longest Substring Without Repeating Characters

采用双指针法:首尾指针移动,并保证首尾之间无重复元素出现;当有重复元素出现时,判断maxLen是否需要更新;class Solution {public: int lengthOfLongestSubstring(string s) { if(s.size()<1) return 0; int begin =...

2018-06-21 21:52:24 100

原创 【DFS】841. Keys and Rooms

class Solution {public: void dfs(int pos,vector<bool> &flag,vector<vector<int>>& rooms) { flag[pos]=true; for(int i = 0;i<rooms[pos].size();i++) ...

2018-06-06 20:26:16 381

原创 151. Reverse Words in a String

关键在于清除多余空格:class Solution {public: void reverseWords(string &s) { int begin = 0; for (; begin < s.size(); begin++) if (s[begin] != ' ') ...

2018-06-01 10:43:59 390

空空如也

空空如也

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

TA关注的人

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