摘要:
1 class Solution 2 { 3 public: 4 vector<int> singleNumber(vector<int>& nums) 5 { 6 int diff = 0; 7 vector<int> res(2,0); 8 for (int num : nums) diff ^ 阅读全文
posted @ 2020-04-12 23:10
Jinxiaobo0509
阅读(106)
评论(0)
推荐(0)
摘要:
1 //很简单 2 class Solution 3 { 4 public: 5 int addDigits(int num) 6 { 7 while(num > 9) 8 { 9 int temp = 0; 10 while(num) 11 { 12 temp += num % 10; 13 nu 阅读全文
posted @ 2020-04-12 22:38
Jinxiaobo0509
阅读(117)
评论(0)
推荐(0)
摘要:
1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), 阅读全文
posted @ 2020-04-12 22:31
Jinxiaobo0509
阅读(149)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 bool isAnagram(string s, string t) 5 { 6 unordered_map<char,int> hash_s,hash_t; 7 for(auto a : s) hash_s[a] ++; 8 for 阅读全文
posted @ 2020-04-12 20:42
Jinxiaobo0509
阅读(125)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 vector<int> diffWaysToCompute(string input) 5 { 6 vector<int> res; 7 for(int i=0; i<input.size(); i++) 8 { 9 if(input 阅读全文
posted @ 2020-04-12 20:38
Jinxiaobo0509
阅读(143)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 bool searchMatrix(vector<vector<int>>& matrix, int target) 5 { 6 if(matrix.empty() || matrix[0].empty()) return false 阅读全文
posted @ 2020-04-12 18:46
Jinxiaobo0509
阅读(121)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 vector<int> productExceptSelf(vector<int>& nums) 5 { 6 int n = nums.size(); 7 vector<int> A(n,1),B(n,1); 8 vector<int 阅读全文
posted @ 2020-04-12 18:36
Jinxiaobo0509
阅读(149)
评论(0)
推荐(0)
摘要:
1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), 阅读全文
posted @ 2020-04-12 18:02
Jinxiaobo0509
阅读(128)
评论(0)
推荐(0)
摘要:
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 阅读全文
posted @ 2020-04-12 17:44
Jinxiaobo0509
阅读(105)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 bool isPowerOfTwo(int n) 5 { 6 return n > 0 && (n & n - 1) == 0; 7 } 8 }; 1 class Solution 2 { 3 public: 4 bool isPow 阅读全文
posted @ 2020-04-12 16:04
Jinxiaobo0509
阅读(122)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 int kthSmallest(TreeNode* root, int k) 5 { 6 stack<TreeNode*> s; 7 TreeNode *cur = root; 8 while(!s.empty() || cur) 9 阅读全文
posted @ 2020-04-12 13:58
Jinxiaobo0509
阅读(183)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 vector<int> majorityElement(vector<int>& nums) 5 { 6 vector<int> res; 7 if (nums.empty()) return res; 8 // 初始化两个候选人ca 阅读全文
posted @ 2020-04-12 13:31
Jinxiaobo0509
阅读(140)
评论(0)
推荐(0)
摘要:
1 //简单题 2 class Solution 3 { 4 public: 5 vector<string> summaryRanges(vector<int>& nums) 6 { 7 vector<string> res; 8 if(nums.empty()) return res; 9 ve 阅读全文
posted @ 2020-04-12 11:59
Jinxiaobo0509
阅读(155)
评论(0)
推荐(0)
摘要:
1 class Solution 2 { 3 public: 4 int calculate(string s) 5 { 6 s += "+";//1、最后一位加一个"+" 7 if (s.empty()) return 0; 8 stack<int> vals; 9 stack<char> ops 阅读全文
posted @ 2020-04-12 11:35
Jinxiaobo0509
阅读(131)
评论(0)
推荐(0)

浙公网安备 33010602011771号