题目: 解答: 1 class Solution { 2 vector<string>ans; 3 void backtracking(string &s,int start) 4 { 5 if(start==s.size()) 6 { 7 ans.emplace_back(s); 8 } 9 fo ...
分类:
其他好文 时间:
2020-05-10 01:21:38
阅读次数:
91
题目: 解答: 1 class Solution { 2 public: 3 int maxValue(vector<vector<int>>& grid) 4 { 5 int m = grid.size(); 6 int n = grid[0].size(); 7 8 for (int i = 0 ...
分类:
其他好文 时间:
2020-05-09 23:45:21
阅读次数:
98
题目: 解答: 1 class Solution { 2 public: 3 vector<int> constructArr(vector<int>& a) 、 4 { 5 int n = a.size(); 6 vector<int> ret(n, 1); 7 8 int left = 1; 9 ...
分类:
编程语言 时间:
2020-05-09 21:41:37
阅读次数:
74
题目: 解答: 1 class Solution { 2 public: 3 vector<vector<int>> findContinuousSequence(int target) 4 { 5 int i = 1; // 滑动窗口的左边界 6 int j = 1; // 滑动窗口的右边界 7 ...
分类:
其他好文 时间:
2020-05-09 21:30:07
阅读次数:
59
题目: 解答: 1 class Solution { 2 public: 3 int maxProfit(vector<int>& prices) 4 { 5 int cost = INT_MAX; 6 int profit = 0; 7 for (int price: prices) 8 { 9 ...
分类:
其他好文 时间:
2020-05-09 20:50:03
阅读次数:
59
题目: 解答: 1 class Solution { 2 public: 3 vector<int> maxSlidingWindow(vector<int>& nums, int k) 4 { 5 if(nums.size() == 0 || k == 1) 6 { 7 return nums; ...
分类:
其他好文 时间:
2020-05-09 20:38:37
阅读次数:
62
题目: 解答: 1 class Solution { 2 public: 3 vector<string> permutation(string str) 4 { 5 vector<string> result; 6 if(str.empty()) 7 { 8 return result; 9 } ...
分类:
其他好文 时间:
2020-05-09 17:02:54
阅读次数:
69
题目: 解答: 1 class Solution { 2 public: 3 int majorityElement(vector<int>& nums) 4 { 5 int x = 0; 6 int votes = 0; 7 for(int num : nums) 8 { 9 if(votes = ...
分类:
编程语言 时间:
2020-05-09 16:54:18
阅读次数:
60
题目: 解答: 1 class Solution { 2 public: 3 vector<int> getLeastNumbers(vector<int>& arr, int k) 4 { 5 vector<int> res; 6 priority_queue<int> q; 7 for (int ...
分类:
其他好文 时间:
2020-05-09 16:45:57
阅读次数:
52
题目: 解答: 方法一:哈希 使用哈希来进行处理,当发现哈希中包含相应的元素时,则表示出现了重复的元素,则返回即可。 1 class Solution { 2 public: 3 int findRepeatNumber(vector<int>& nums) 4 { 5 std::set<int> ...
分类:
编程语言 时间:
2020-05-09 11:59:30
阅读次数:
63