目录
离散:
续sevent:
对 自反 , 反自反 , 对称 , 反对称 , 传递 的明白了当的解释:
自反: . ( 恒等关系.
反自反: .
对称: .
反对称: . ( .
传递: . ( 是右复合. 结果 .
概率论知识点:
第一章:
频率与概率:
频率: 1) 非负. 2)规范. 3)可加.
*频率在基数大时 , 无限接近于 P (概率.
概率: 事件发生内在的因素.
公理化: 1)描述. 2)古典. 3)几何. 4)统计.
性质: 同样的 1) 非负. 2)规范. 3)可加.
a. .
b. .
c. .
d. . *推论: .
e. (加法) . *推论: .
*可对无限个事件满足.
几何概型: 概率为 0 , 也有可能发生.
条件概率: 在B已经发生的概率下 , A发生的概率.
对比: : 无条件概率 样本空间为R. : 条件概率 样本空间为B.
计算公式: 1) . 2).
乘法公式: .
*推论: .
贝叶斯公式: 知果推因.
事件的独立性 . 定义: A的概率不被B影响.
leetcode每日一题:
不会写orz. 让我水过去吧.
struct State{
string board;
string hand;
int step;
State(const string & board, const string & hand, int step) {
this->board = board;
this->hand = hand;
this->step = step;
}
};
class Solution {
public:
string clean(const string & str){
string res;
vector<pair<char,int>> st;
for (auto c : str) {
while (!st.empty() && c != st.back().first && st.back().second >= 3) {
st.pop_back();
}
if (st.empty() || c != st.back().first) {
st.push_back({c,1});
} else {
st.back().second++;
}
}
if (!st.empty() && st.back().second >= 3) {
st.pop_back();
}
for (int i = 0; i < st.size(); ++i) {
for (int j = 0; j < st[i].second; ++j) {
res.push_back(st[i].first);
}
}
return res;
}
int findMinStep(string board, string hand) {
unordered_set<string> visited;
sort(hand.begin(), hand.end());
visited.insert(board + " " + hand);
queue<State> qu;
qu.push(State(board, hand, 0));
while (!qu.empty()) {
State curr = qu.front();
qu.pop();
for (int j = 0; j < curr.hand.size(); ++j) {
// 第 1 个剪枝条件: 当前选择的球的颜色和前一个球的颜色相同
if (j > 0 && curr.hand[j] == curr.hand[j - 1]) {
continue;
}
for (int i = 0; i <= curr.board.size(); ++i) {
// 第 2 个剪枝条件: 只在连续相同颜色的球的开头位置插入新球
if (i > 0 && curr.board[i - 1] == curr.hand[j]) {
continue;
}
// 第 3 个剪枝条件: 只在以下两种情况放置新球
bool choose = false;
// 第 1 种情况 : 当前球颜色与后面的球的颜色相同
if (i < curr.board.size() && curr.board[i] == curr.hand[j]) {
choose = true;
}
// 第 2 种情况 : 当前后颜色相同且与当前颜色不同时候放置球
if (i > 0 && i < curr.board.size() && curr.board[i - 1] == curr.board[i] && curr.board[i] != curr.hand[j]){
choose = true;
}
if (choose) {
string new_board = clean(curr.board.substr(0,i) + curr.hand[j] + curr.board.substr(i));
string new_hand = curr.hand.substr(0,j) + curr.hand.substr(j + 1);
if (new_board.size() == 0) {
return curr.step + 1;
}
if (!visited.count(new_board + " " + new_hand)) {
qu.push(State(new_board, new_hand, curr.step + 1));
visited.insert(new_board + " " + new_hand);
}
}
}
}
}
return -1;
}
};
// 作者:LeetCode-Solution
// 链接:https://leetcode-cn.com/problems/zuma-game/solution/zu-ma-you-xi-by-leetcode-solution-lrp4/
// 来源:力扣(LeetCode)
// 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
一八年夏天的蝉 , 便以为抓住了整个夏天.Day Eighteen -- 一八年夏至.