Skip to content

Commit 648e39e

Browse files
committed
124
1 parent 236c342 commit 648e39e

File tree

1 file changed

+93
-1
lines changed

1 file changed

+93
-1
lines changed

刷题/LeetCode分类练习篇.md

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,7 @@ public:
23772377
```
23782378

23792379
## 595. Big Countries
2380-
```
2380+
```SQL
23812381
# Write your MySQL query statement below
23822382
SELECT name, population, area
23832383
FROM World
@@ -2438,6 +2438,98 @@ public:
24382438
return false;
24392439
}
24402440
};
2441+
```
2442+
## 1078. Occurrences After Bigram
2443+
```C++
2444+
class Solution {
2445+
public:
2446+
vector<string> findOcurrences(string text, string first, string second) {
2447+
vector<string> tmp,res;
2448+
string str = "";
2449+
for (int i = 0; i < text.length(); i++) {
2450+
if (text[i] != ' ') str += text[i];
2451+
else {
2452+
tmp.push_back(str);
2453+
str = "";
2454+
}
2455+
}
2456+
tmp.push_back(str);
2457+
for (int i = 0; i < tmp.size() - 2; i++) {
2458+
if (tmp[i] == first && tmp[i + 1] == second) res.push_back(tmp[i + 2]);
2459+
}
2460+
return res;
2461+
}
2462+
};
2463+
```
2464+
## 852. Peak Index in a Mountain Array
2465+
```C++
2466+
class Solution {
2467+
public:
2468+
int peakIndexInMountainArray(vector<int>& A) {
2469+
int i = 0;
2470+
for (; i < A.size() - 1; i++) {
2471+
if (A[i] > A[i + 1]) break;
2472+
}
2473+
return i;
2474+
}
2475+
};
2476+
```
2477+
## 933. Number of Recent Calls
2478+
```C++
2479+
class RecentCounter {
2480+
public:
2481+
queue<int> q;
2482+
RecentCounter() {
2483+
2484+
}
2485+
2486+
int ping(int t) {
2487+
q.push(t);
2488+
while (q.front() < t - 3000)
2489+
q.pop();
2490+
return q.size();
2491+
}
2492+
};
2493+
```
2494+
## 944. Delete Columns to Make Sorted
2495+
```C++
2496+
class Solution {
2497+
public:
2498+
int minDeletionSize(vector<string>& A) {
2499+
if (A.size() == 0) return 0;
2500+
vector<char> inc(A[0].size(), 'a');
2501+
vector<bool> flag(A[0].size(), true);
2502+
for (auto s : A) {
2503+
for (int i = 0; i < s.size(); i++) {
2504+
if (s[i] >= inc[i]) inc[i] = s[i];
2505+
else flag[i] = false;
2506+
}
2507+
}
2508+
return count(flag.begin(),flag.end(),false);
2509+
}
2510+
};
2511+
```
2512+
## 627. Swap Salary
2513+
```SQL
2514+
# Write your MySQL query statement below
2515+
update salary set sex= CHAR(ASCII('f') + ASCII('m') - ASCII(sex));
2516+
```
2517+
## 700. Search in a Binary Search Tree
2518+
```C++
2519+
class Solution {
2520+
public:
2521+
TreeNode* searchBST(TreeNode* root, int val) {
2522+
if (root == nullptr) return nullptr;
2523+
if (root->val == val) return root;
2524+
else if (root->val > val) return searchBST(root->left, val);
2525+
else return searchBST(root->right, val);
2526+
}
2527+
};
2528+
2529+
```
2530+
2531+
```C++
2532+
24412533
```
24422534

24432535
```C++

0 commit comments

Comments
 (0)