Skip to content

Commit e326b51

Browse files
committed
update
1 parent ca0ee44 commit e326b51

26 files changed

+1127
-68
lines changed

Diff for: Algorithm_full_features/others/BloomFilter.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**
2+
* 实现一个布隆过滤器功能
3+
*/

Diff for: codeForces/codeForces_1B_SpreadSheet.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include<stdio.h>
2+
#include<map>
3+
#include<utility>
4+
#include<math.h>
5+
6+
using namespace std;
7+
8+
int main()
9+
{
10+
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution {
2+
public:
3+
int distinctEchoSubstrings(string text) {
4+
vector<string> ret;
5+
int textLength = text.length();
6+
for (int i = 0; i < textLength; i++) {
7+
for (int j = i + 1; j < textLength; j += 2) { // 偶数个字符的子串
8+
bool flag = true;
9+
for (int k = 0; k < (j - i + 1) / 2; k++) {
10+
if (text[i + k] != text[(j + i) / 2 + 1 + k]) {
11+
flag = false;
12+
break;
13+
}
14+
}
15+
if (flag) {
16+
string temp = text.substr(i, (j - i) + 1);
17+
ret.push_back(temp);
18+
}
19+
}
20+
}
21+
set<string>s(ret.begin(), ret.end()); // 去重
22+
23+
return s.size();
24+
}
25+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
class Solution {
2+
public:
3+
vector<int> peopleIndexes(vector<vector<string>>& favoriteCompanies) {
4+
5+
}
6+
};
7+
8+
// ========== 尝试一 ==========
9+
10+
// <?php
11+
12+
// /**
13+
// * Brute-force , 明显会超时
14+
// *
15+
// */
16+
// class Solution {
17+
// // 判断数组 a 是否为数组 b 的子集
18+
// function isSubset($a, $b) {
19+
// $flag = 1;
20+
// foreach ($a as $item) {
21+
// if (in_array($item, $b)) {
22+
// continue;
23+
// } else {
24+
// $flag = 0;
25+
// break;
26+
// }
27+
// }
28+
29+
// if ($flag) {
30+
// return 1;
31+
// } else {
32+
// return 0;
33+
// }
34+
// }
35+
36+
// /**
37+
// * @param String[][] $favoriteCompanies
38+
// * @return Integer[]
39+
// */
40+
// function peopleIndexes($favoriteCompanies) {
41+
// $record = [];
42+
// for ($i = 0; $i < count($favoriteCompanies); $i++) {
43+
// if (isset($record[$i])) {
44+
// continue;
45+
// }
46+
// for ($j = 0; $j < count($favoriteCompanies); $j++) {
47+
// if (isset($record[$j]) || $i == $j) {
48+
// continue;
49+
// }
50+
// if ($this->isSubset($favoriteCompanies[$j], $favoriteCompanies[$i])) {
51+
// $record[$j] = 1;
52+
// }
53+
// }
54+
// }
55+
56+
// $ret = [];
57+
// for ($i = 0; $i < count($favoriteCompanies); $i++) {
58+
// if (isset($record[$i])) {
59+
// continue;
60+
// }
61+
// $ret[] = $i;
62+
// }
63+
64+
// return $ret;
65+
// }
66+
// }

Diff for: contest/leetcode_week_189/[editing]leetcode_5414_People_Whose_List_of_Favorite_Companies_Is_Not_a_Subset_of_Another_List.php

-53
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Solution {
2+
public:
3+
vector<vector<int>> combinationSum2 (vector<int> &num, int target)
4+
{
5+
//
6+
}
7+
};

Diff for: leetcode_solved/[editing]leetcode_0042_Trapping_Rain_Water.cpp

+1-2
Large diffs are not rendered by default.
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public:
3+
int jump(vector<int>& nums) {
4+
5+
}
6+
};

Diff for: leetcode_solved/[editing]leetcode_0051_N-Queens.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public:
3+
vector<vector<string>> solveNQueens(int n) {
4+
5+
}
6+
};

Diff for: leetcode_solved/[editing]leetcode_0078_Subsets.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public:
3+
vector<vector<int>> subsets(vector<int>& nums) {
4+
//
5+
}
6+
};

Diff for: leetcode_solved/[editing]leetcode_0088_Merge_Sorted_Array.cpp

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
/**
2+
* AC:
3+
* 思路:用位运算实现,从右边开始每四位计算一次, << 4
4+
*
5+
*/
16
class Solution {
27
public:
38
string toHex(int num) {
4-
9+
string ans = "";
10+
while(num) {
11+
// num
12+
}
513
}
614
};
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
[editing]leetcode_0653_Two_Sum_IV_-_Input_is_a_BST.cpp
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), left(NULL), right(NULL) {}
8+
* };
9+
*/
10+
class Solution {
11+
public:
12+
bool findTarget(TreeNode* root, int k) {
13+
14+
}
15+
};

Diff for: leetcode_solved/[editing]leetcode_0804_Unique_Morse_Code_Words.cpp

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class Solution {
2+
public:
3+
vector<int> kWeakestRows(vector<vector<int>>& mat, int k) {
4+
int row = mat.size(), col = mat[0].size(), temp;
5+
unordered_map<int, int> record;
6+
vector<int> ret;
7+
8+
for (int i = 0; i < row; i++) {
9+
temp = 0;
10+
for (int j = 0; j < col; j++) {
11+
temp += mat[i][j];
12+
}
13+
record[i] = temp;
14+
}
15+
16+
// 按照 key/value 的 value 排序。
17+
std::sort(record.begin(), record.end(), [=](std::pair<int, int>& a, std::pair<int, int>& b) { return a.second < b.second; });
18+
19+
int count = 0;
20+
unordered_map<int, int>::iterator iter = record.begin();
21+
while (iter != record.end() && count < k) {
22+
ret.push_back(iter->first);
23+
count++;
24+
}
25+
26+
return ret;
27+
}
28+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public:
3+
int numOfMinutes(int n, int headID, vector<int>& manager, vector<int>& informTime) {
4+
5+
}
6+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public:
3+
double frogPosition(int n, vector<vector<int>>& edges, int t, int target) {
4+
5+
}
6+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution {
2+
public:
3+
vector<string> stringMatching(vector<string>& words) {
4+
int size = words.size();
5+
6+
7+
}
8+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Solution {
2+
public:
3+
string destCity(vector<vector<string>>& paths) {
4+
int pathSize = paths.size();
5+
vector<int> record(pathSize, 0);
6+
string left = paths[0][0],right = paths[0][1];
7+
8+
for (int i = 0; i < pathSize; i++) {
9+
record[i] = 1;
10+
for (int j = i + 1; j < pathSize; j++) {
11+
if (record[j]) {
12+
continue;
13+
}
14+
15+
if (paths[i][0] == paths[j][1]) {
16+
left = paths[j][0];
17+
right = paths[i][1];
18+
record[j] = 1;
19+
} else if (paths[i][1] == paths[j][0]) {
20+
left = paths[i][0];
21+
right = paths[j][1];
22+
record[j] = 1;
23+
}
24+
}
25+
}
26+
27+
return right;
28+
}
29+
};
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Solution {
22
public:
3-
int removePalindromeSub(string s) {
3+
int countTriplets(vector<int>& arr) {
44

55
}
66
};

Diff for: leetcode_solved/leetcode_0088_Merge_Sorted_Array.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public:
3+
void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) {
4+
5+
}
6+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public:
3+
int balancedStringSplit(string s) {
4+
int size = strlen(s);
5+
6+
int countL = 0, countR = 0;
7+
while(s) {
8+
9+
}
10+
}
11+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public:
3+
int countNegatives(vector<vector<int>>& grid) {
4+
int count = 0;
5+
for (int i = 0; i < grid.size(); i++) {
6+
// 二分查找,找到从左边起第一个负数
7+
int left = 0, right = grid[0].size() - 1;
8+
int mid = (left + right) / 2;
9+
10+
while (left < right) {
11+
if (grid[i][mid] >= 0) {
12+
left = mid + 1;
13+
} else {
14+
right = mid - 1;
15+
}
16+
}
17+
}
18+
19+
return count;
20+
}
21+
};

0 commit comments

Comments
 (0)